Nesting of #include

If I #include an exclusion list, and that file also contains a #include, will all of the exclusions in both #included files be applied?

(I promise not to go circular!) TIA

Empirical results show that it works. I’m wondering whether there are gotchas waiting.

1 Like

In general this is evil. Even including out of the folder root I consider evil.

A better way would be to symlink the files into the folder.

Symlinks aren’t portable, nor is the to be included path necessary in the same path on ever system (ok you could ignore the symlink in the included file to avoid that problem :slight_smile: ). I personally like and use the evilness of having a global, shared ignores file, by placing it in one Syncthing folder, and including it from other folders using paths outside of the folder. I do agree that’s hardly a beatiful, simple and robust mechanism, but it works.

The reason I consider them evil is because it is the only thing that leaks through the filesystem containment abstraction.

2 Likes

I have many different synced folders on my network, with different sets of folders on different machines. Configuration management for ignore-lists is a problem:

  • I sometimes add an exclude to the list for a folder on one machine, but I forget to add it to other machines that share that folder
  • I sometimes add an exclude to the list for a folder on a machine, but I forget to add it to my offline copy, and then when I have to rebuild the machine, I have no up-to-date record of the exclude list.

I’d like to have a centralized folder with a single “master” exclude list for each shared folder, and push this out to all the machines. Each sync-folder on each machine to have a single #include, to make it simple to rebuild a machine.

I’d like to have that “master” exclude for a folder:

  • #include windows-stuff-to-ignore.inc
  • #include mac-stuff-to-ignore.inc
  • Line after line of stuff to ignore which is unique to this folder

By having a single, standardized top-level #include for each shared folder, I make it easy to rebuild that instance of Syncthing.

By having the master file #include windows and mac lists, I make it easy to ensure that ALL machines get updated, when I discover some new noise file created by Windows or Apple.

I store all of my included files is a single directory, which is pushed from a central machine to all other machines. Each sync-folder on every machine has a symlink to the folder of includes, so the “top level” statements look like #include .stglobals/folder-name-here.inc and they contain “child” includes like #include .stglobals/mac-crap.inc.

If nested includes are evil, what would be a better way to:

  • Have a single #include for each folder entered into Syncthing UI
  • And maintain lists of files which get excluded on EVERY machine
  • And be able to have excludes which are unique to a synchronized folder

Thanks!

Although symlinks are not entirely portable, directory symlinks work pretty well for Windows, Mac, and Linux. That thoroughly covers my bases. A symlinked “.stglobals” folder makes all my #includes appear to come from a folder at the top-level of the shared-folder, making it possible for me to maintain my exclude lists centrally, and push them out to all machines.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.