@@ -18,7 +18,7 @@ const schema = z
1818 deviceId : z
1919 . string ( )
2020 . describe ( 'The Syncthing device ID (e.g. XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX)' ) ,
21- name : z
21+ deviceName : z
2222 . string ( )
2323 . optional ( )
2424 . describe ( 'Human-readable label for this device' ) ,
@@ -79,7 +79,7 @@ export class SyncthingDeviceResource extends Resource<SyncthingDeviceConfig> {
7979 identifyingParameters : [ 'deviceId' ] ,
8080 } ,
8181 parameterSettings : {
82- name : { type : 'string' , canModify : true } ,
82+ deviceName : { type : 'string' , canModify : true } ,
8383 addresses : { type : 'array' , canModify : true } ,
8484 autoAcceptFolders : { type : 'boolean' , canModify : true } ,
8585 paused : { type : 'boolean' , canModify : true } ,
@@ -107,10 +107,10 @@ export class SyncthingDeviceResource extends Resource<SyncthingDeviceConfig> {
107107
108108 async create ( plan : CreatePlan < SyncthingDeviceConfig > ) : Promise < void > {
109109 const $ = getPty ( ) ;
110- const { deviceId, name , addresses, autoAcceptFolders, paused, compression, maxSendKbps, maxRecvKbps } =
110+ const { deviceId, deviceName , addresses, autoAcceptFolders, paused, compression, maxSendKbps, maxRecvKbps } =
111111 plan . desiredConfig ;
112112
113- const args = buildDeviceAddArgs ( { deviceId, name , addresses, autoAcceptFolders, paused, compression, maxSendKbps, maxRecvKbps } ) ;
113+ const args = buildDeviceAddArgs ( { deviceId, deviceName , addresses, autoAcceptFolders, paused, compression, maxSendKbps, maxRecvKbps } ) ;
114114 await $ . spawn ( `syncthing cli config devices add ${ args } ` , { interactive : true } ) ;
115115 }
116116
@@ -150,19 +150,14 @@ export class SyncthingDeviceResource extends Resource<SyncthingDeviceConfig> {
150150 return null ;
151151 }
152152
153- let ids : string [ ] ;
154- try {
155- ids = JSON . parse ( listData ) as string [ ] ;
156- } catch {
157- return null ;
158- }
153+ const ids = listData . split ( '\n' ) . map ( ( s ) => s . trim ( ) ) . filter ( Boolean ) ;
159154
160155 if ( ! ids . includes ( deviceId ) ) {
161156 return null ;
162157 }
163158
164159 // Fetch the full device configuration
165- const { status, data } = await $ . spawnSafe ( `syncthing cli config devices ${ deviceId } ` ) ;
160+ const { status, data } = await $ . spawnSafe ( `syncthing cli config devices ${ deviceId } dump-json ` ) ;
166161 if ( status !== SpawnStatus . SUCCESS ) {
167162 return null ;
168163 }
@@ -180,7 +175,7 @@ export class SyncthingDeviceResource extends Resource<SyncthingDeviceConfig> {
180175function deviceFromRaw ( raw : RawDevice ) : Partial < SyncthingDeviceConfig > {
181176 return {
182177 deviceId : raw . deviceID ,
183- name : raw . name || undefined ,
178+ deviceName : raw . name || undefined ,
184179 addresses : raw . addresses ,
185180 compression : raw . compression as SyncthingDeviceConfig [ 'compression' ] ,
186181 autoAcceptFolders : raw . autoAcceptFolders ,
@@ -192,7 +187,7 @@ function deviceFromRaw(raw: RawDevice): Partial<SyncthingDeviceConfig> {
192187
193188function deviceOptionCliPath ( key : keyof SyncthingDeviceConfig ) : string | undefined {
194189 const map : Partial < Record < keyof SyncthingDeviceConfig , string > > = {
195- name : 'name' ,
190+ deviceName : 'name' ,
196191 autoAcceptFolders : 'autoAcceptFolders' ,
197192 paused : 'paused' ,
198193 compression : 'compression' ,
@@ -206,7 +201,7 @@ function buildDeviceAddArgs(config: Partial<SyncthingDeviceConfig>): string {
206201 const parts : string [ ] = [ ] ;
207202
208203 if ( config . deviceId ) parts . push ( `--device-id ${ config . deviceId } ` ) ;
209- if ( config . name ) parts . push ( `--name "${ config . name } "` ) ;
204+ if ( config . deviceName ) parts . push ( `--name "${ config . deviceName } "` ) ;
210205 if ( config . addresses ?. length ) parts . push ( `--addresses ${ config . addresses . join ( ',' ) } ` ) ;
211206 if ( config . autoAcceptFolders !== undefined )
212207 parts . push ( `--auto-accept-folders=${ config . autoAcceptFolders } ` ) ;
0 commit comments