Nested folders howto.

Hello, everyone.

I have read the FAQ, but the FAQ only says “you can nest shared folders if you know what you are doing”. Well, how do I learn enough to nest folders successfully?

My use-case is the following:

I have a “master” machine, that is my laptop, and in my ~/Devices/ I have full copies of my mobile devices synced by Syncthing:

  1. ~/Devices/Phone1
  2. ~/Devices/Bookreader
  3. ~/Devices/Phone2

I want a folder, say, ~/Work to be available on all those devices:

  1. ~/Work
  2. ~/Devices/Phone1/Work
  3. ~/Devices/Bookreader/Work
  4. ~/Devices/Phone2/Work

When I had only two devices, I just made ~/Work to be a symlink to ~/Devices/Phone1/Work.

However, with multiple devices this does not seem to be possible.

My initial idea was to run Unison locally on the laptop, and tell it to sync ~/Work. This should work if the laptop is always running, but requires a separate tool, and would not work if the laptop is turned off, but Phone1 and Phone2 are connected to the same network.

So, is there some marvellous Syncthing trick to sync that ~/Work folder?

Using only Syncthing, it is not possible to share ~/Work as part of ~/Devices, because: Syncthing syncs symlinks, but it does not follow them.

Share the ~/Work folder directly with all devices instead.

This is the way to go. I would also suggest ignore the “Work” folder on your mobile devices as it sounds like it will be a nested folder in your main folder that is synced to the laptop. I do more or less the same thing on my phone.

So your idea is ignoring Phone1/Work on that phone, make ~/Work a separate shared directory, and sync it into Phone1/Work?

And do the same for all devices?

I think the comment about ignoring was confusing, se I am taking the liberty of repeating myself with some added clarification. You wrote:

Don’t do this. Don’t let Work be involved at all in the ~/Devices folders.

I wrote:

I can’t “not do this”, because this is precisely what I need. I find it really convenient to have a full copy of each device internal storage under ~/Devices/. But I also need to have a copy of Work on each of those devices.

Let’s assume that your devices have the following directory trees:

Bookreader
├── PDF
└── Work
Phone1
├── DCIM
├── Documents
└── Work
Phone2
├── DCIM
├── Documents
└── Work
laptop
├── Devices
│   ├── Bookreader
│   ├── Phone1
│   └── Phone2
└── Work

You’d need a total of four Syncthing folders on your laptop – one for each mobile device plus the multi-device Work folder.

If your mobile devices are set to “Send Only” to your laptop which is “Receive Only” for all directories except the Work folder, then managing the ignore patterns only on the laptop will be fine. Under the Syncthing folder root for each device you’ll have a .stignore file:

laptop
├── Devices
│   ├── Bookreader
│   │   └── .stignore
│   ├── Phone1
│   │   └── .stignore
│   └── Phone2
│   │   └── .stignore
└── Work

The only pattern you’ll need in .stignore is:

/Work/

Now you can set up and share Work on your laptop in a bidirectional sync with your mobile devices.

The “Bookreader” Syncthing folder on your laptop will exclude the Work directory on Bookreader’s internal storage, while a separate “Work” Syncthing folder will take care of only mirroring the Work directory between Bookreader and the laptop. Same goes for the other mobile devices. Repeat for the other devices.

1 Like