Useful .stignore Patterns

There is always a first time :heart_eyes: Anyway, I understand the argument against variables, though, it would make it generic within one environment, e. g.

c:\users\%USERNAME%\something

would work for all users in a windows environment and make the admins life easier.

Except the ignore patterns are relative to the synced folder’s root anyway…

I want to sync only .jpg files inside sub folder and ignore all other folders.

I’m syncing DCIM/ folder to my PC:

Camera/
Screenshots/
SomeFolder/

And I want to sync only Camera images without large .mp4 files to other mobile phone. So this .stignore should work:

*.mp4
!/Camera/
*

It synced right files, but is’s reporting that all other files are out of sync?

Make sure that on both sides you’ve the same .stignore and if that is OK, then a restart of one or both of the sides could resolve it.

I’ve just tried to have #include ~/.stignore in my various .stignores, in order to add the defaults above. This seems to work, as far as I can tell. So while there is no variable substitution, tilde expansion is available.

Are you sure this works correctly? According to another thread, that should not work:

I’m confused now…

  1. I’ve double-checked, and the tilde effectively is not expanded.
  2. When looking at the source code, I see tests that verify that error messages are printed when the #include directives are invalid (e.g., testInvalidPatterns).
  3. None of these errors shows up in my logs. This made me believe in the first place that tilde expansion worked.

Does anybody have more information about this? Would it make sense to file a bug for the missing error message?

Yes, please do, I’ve thought about it and forgotten it several times already.

The problem is that we’re specifically suppressing “file not found”, as we don’t want to log an error when trying to load a .stignore when there is none. But that also means we suppress a “file not found” when parsing #includes.

We can of course just check first if it exists, and if it does we actually do print whatever error we do run into when processing it. In the rare race condition where the user manages to delete the .stignore file between that check and the open, they’ll get the error and it’s no big deal…

Reported as #2309.

1 Like

Hello,

this is a great help!

I’ve compiled a list from my own experiences (and from this forum). Maybe Cyphase wants to update his great first post with some more exclusions.

Please note: Since I’m not using BTSync anymore, those are still unique in Cyphase’s post…

//---Mac-specific---//
.DS_Store
.DocumentRevisions-V100
.Spotlight-V100
.TemporaryItems
.Trashes
.fseventsd
.localized
//temp file while syncing with (rather from) iCloud
.iCloud*
//Mac OS Metadata on Windows or Linux filesystems
._*

//---Windows-Specific---//
desktop.ini
Thumbs.db
$RECYCLE.BIN

//---Linux-specific---//
.Trash-*

//---QNAP-specific---//
.@__thumb
.AppleDB

//---Synology-specific---//
@eaDir

//---Application-specific---//
//-Syncthing
.stignore
.stfolder
//-vi(m)
*.*.swp
//-Dropbox
.dropbox
.dropbox.attr
//-Microsoft Office
~*
//-KDE
.directory
//-Parallels Desktop on Mac
.parallels-vm-directory
1 Like

Hi @maelcum Not sure why you are listing .stignore and .stfolder, they don’t sync.

I like to sync the ~MicrosoftOffice lock files to reduce the chance of conflicts. If it is on a node when I try to open it I know there is a good chance I am about to create a conflict.

@Cyphase, since the thread is back up the top it might be worth updating your original post. I don’t think it is worth ignoring the *.part or *.crdownload any more because we should be able to pull some of the blocks from them once the move/rename happens. Probably the same thing for .iCloud*.

Perhaps one one of the core developers could correct me if I am wrong.

1 Like

Hey Kluppy,

> Not sure why you are listing .stignore and .stfolder, they don’t sync.
yep, I know. The ignore list is the file I’d consult if in doubt what should sync. the .stignore and .stfolder are there as a reminder for me. Just that.

Thanks for the ping @kluppy, and to everyone else who has commented with suggestions. I’m too tired to do an update at the moment :smile:, but I’ll do one the next chance I get. I’m glad to see this post has gotten so many views and comments in the time that I’ve been inactive.

Maybe a wiki page would be useful, so that everyone can edit it?

5 Likes

My updated .stglobal, thanks to wweichs great hint (thanks!!) here:

//---Mac-specific---//
(?d).DS_Store
.DocumentRevisions-V100
.Spotlight-V100
.TemporaryItems
.Trashes
.fseventsd
(?d).localized
.iCloud
//Mac OS Metadata on Windows or Linux filesystems
(?d)._*

//---Windows-Specific---//
(?d)desktop.ini
(?d)Thumbs.db
(?d)$RECYCLE.BIN

//---Linux-specific---//
.Trash-*

//---QNAP-specific---//
(?d).@__thumb
(?d).AppleDB

//---Synology-specific---//
(?d)@eaDir

//---Application-specific---//
//-Syncthing
(?d).stignore
(?d).stfolder
//-vi(m)
(?d)*.*.swp
//-Dropbox
.dropbox
.dropbox.attr
//-Microsoft Office
(?d)~*
//-KDE
.directory


//---OTHER---//
Microsoft-Benutzerdaten
Notizbuch von Wolf.url
Outlook-Dateien
RDC Connections
.parallels-vm-directory
Default.rdp
2 Likes

vim swap files are, in order of creation: .file.swp, .file.swo, .file.swn.

The pattern for these is therefore:

// vim swap files
.*.sw[a-p] # vim uses 'o' then, 'n'... back to 'a'.
1 Like

Where do you put your .stglobalignore file?

There is no global ignore. Read the docs about includes.

I was asking about the file the OP proposed in the original post which started this thread. What are you talking about?

1 Like

Syncthing recognizes .stignore file in the base directory of a share, and parses it’s contents according to documentation:

https://docs.syncthing.net/users/ignoring.html#patterns:

A pattern beginning with #include results in loading patterns from the named file. It is an error for a file to not exist or be included more than once. Note that while this can be used to include patterns from a file in a subdirectory, the patterns themselves are still relative to the folder root. Example: #include more-patterns.txt.

Meaning: if you write in .stignore the line: #include .stglobalignores, it’ll search for a .stglobalignores file in the same place that .stignore resides, and then parse .stglobalignore’s contents as a continuation of .stingnore.

(The point of using extra file in addition to the base .stignore, it that .stignore itself is device specific, that is - it won’t sync to other devices. So people use #include some_file_with_patterns_to_sync to add ingore patterns they like to be synced across several devices.)

3 Likes