@@ -40,6 +40,7 @@ type Configuration struct {
4040// FolderConfiguration holds information about shared folder in ST
4141type FolderConfiguration struct {
4242 ID string
43+ Label string
4344 Path string
4445 RescanIntervalS int
4546}
@@ -278,7 +279,7 @@ func main() {
278279 }
279280 stChans := make (map [string ]chan STEvent , len (folders ))
280281 for _ , folder := range folders {
281- Debug .Println ("Installing watch for " + folder .ID )
282+ Debug .Println ("Installing watch for " + folder .Label )
282283 stChan := make (chan STEvent )
283284 stChans [folder .ID ] = stChan
284285 go watchFolder (folder , stChan )
@@ -377,15 +378,22 @@ func getFolders() []FolderConfiguration {
377378 if err != nil {
378379 log .Fatalln (err )
379380 }
380- return cfg .Folders
381+ // Use folder label unless it's empty
382+ folders := cfg .Folders ;
383+ for f := range folders {
384+ if len (folders [f ].Label ) == 0 {
385+ folders [f ].Label = folders [f ].ID ;
386+ }
387+ }
388+ return folders ;
381389}
382390
383391// watchFolder installs inotify watcher for a folder, launches
384392// goroutine which receives changed items. It never exits.
385393func watchFolder (folder FolderConfiguration , stInput chan STEvent ) {
386394 folderPath := expandTilde (folder .Path )
387395 ignores := ignore .New (false )
388- Trace .Println ("Getting ignore patterns for " + folder .ID )
396+ Trace .Println ("Getting ignore patterns for " + folder .Label )
389397 ignores .Load (filepath .Join (folderPath , ".stignore" ))
390398 fsInput := make (chan string )
391399 c := make (chan notify.EventInfo , maxFiles )
@@ -396,21 +404,21 @@ func watchFolder(folder FolderConfiguration, stInput chan STEvent) {
396404 notify .SetDoNotWatch (ignoreTest )
397405 if err := notify .Watch (filepath .Join (folderPath , "..." ), c , notify .All ); err != nil {
398406 if strings .Contains (err .Error (), "too many open files" ) || strings .Contains (err .Error (), "no space left on device" ) {
399- msg := "Failed to install inotify handler for " + folder .ID + ". Please increase inotify limits, see http://bit.ly/1PxkdUC for more information."
407+ msg := "Failed to install inotify handler for " + folder .Label + ". Please increase inotify limits, see http://bit.ly/1PxkdUC for more information."
400408 Warning .Println (msg , err )
401409 informError (msg )
402410 return
403411 } else {
404- Warning .Println ("Failed to install inotify handler for " + folder .ID + "." , err )
405- informError ("Failed to install inotify handler for " + folder .ID + ": " + err .Error ())
412+ Warning .Println ("Failed to install inotify handler for " + folder .Label + "." , err )
413+ informError ("Failed to install inotify handler for " + folder .Label + ": " + err .Error ())
406414 return
407415 }
408416 }
409417 defer notify .Stop (c )
410418 go accumulateChanges (debounceTimeout , folder .ID , folderPath , dirVsFiles , stInput , fsInput , informChange )
411- OK .Println ("Watching " + folder .ID + ": " + folderPath )
419+ OK .Println ("Watching " + folder .Label + ": " + folderPath )
412420 if folder .RescanIntervalS < 1800 && delayScan <= 0 {
413- OK .Printf ("The rescan interval of folder %s can be increased to 3600 (an hour) or even 86400 (a day) as changes should be observed immediately while syncthing-inotify is running." , folder .ID )
421+ OK .Printf ("The rescan interval of folder %s can be increased to 3600 (an hour) or even 86400 (a day) as changes should be observed immediately while syncthing-inotify is running." , folder .Label )
414422 }
415423 // will we ever get out of this loop?
416424 for {
@@ -922,7 +930,7 @@ func waitForSyncAndExitIfNeeded(folders []FolderConfiguration) {
922930 }
923931 }
924932 if ! seen {
925- Warning .Println ("Folder " + newF .ID + " changed" )
933+ Warning .Println ("Folder " + newF .Label + " changed" )
926934 same = false
927935 }
928936 }
0 commit comments