Skip to content

A tool to conveniently ignore files and folders from Dropbox sync.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

mweirauch/dropignore

Repository files navigation

dropignore

A tool to conveniently ignore files and folders from Dropbox sync.

License Apache-2.0 or MIT Build status

What this tool is and is not

dropignore allows you to ignore files and folders according to a set of matching patterns defined in a global configuration file which is living outside of your Dropbox folder.

As the selective sync feature got broken (see Motivation) dropignore uses the extended file system attributes solution.

This is currently not a gitignore-style-solution everbody is begging for. I am still waiting for the current developments on Dropbox' side.

Installation and Usage

You can download a binary release for Linux, macOS and Windows on the Releases page or compile and install it yourself in case you got a Rust installation set up:

cargo install --git https://github.com/mweirauch/dropignore

After you have installed the binary you need to create a configuration file which contains the ignore and skip specifications of the file or folder names you want to ignore (not sync) or skip (keep synced) with your Dropbox. Providing skip specifications is optional. You just need them in case an ignore specification is too broad and would include any files or folders you don't want to be ignored.

The configuration file locations are as follows:

System Location
Linux dist. /home/charly/.config/dropignore/dropignore.yml
macOS /Users/charly/Library/Application Support/dropignore/dropignore.yml
Windows C:\Users\charly\AppData\Roaming\dropignore\config\dropignore.yml

The configuration file could look like this:

matcher:
  ignore-specs:
    - pattern: "**/build"
    - pattern: "**/target"
  skip-specs:
    - pattern: "**/src/target"

Any matching skip-spec always wins over a previous matching ignore-spec. So with the previous configuration the folders myproject/target and myproject/src/target would be selected as ignore candidates but the skip-spec would only allow for the former to be actually ignored.

The supported glob patterns can be found in the globset project.

Any dot-directories (e.g. ".git") encountered while scanning will not be recursed into any further and thus no ignore matching will be performed on their contents. Such directories should either be ignored or synced entirely.

It is recommended to use the -n (dry-run) option when testing new ignore or skip specifications!

Standalone Usage

One-time scanning

dropignore scan [-n] /path/to/Dropbox/

This will scan the given path (or the current working directory if omitted) for ignore candidates.

Periodic watching

dropignore watch [-n] /path/to/Dropbox/

This will first perform a scan (see above) and then watch all subsequent file system changes and check for ignore candidates as they occur. Currently, these changes are handled after a delay of 2 seconds.

Run as a daemon

In order to run dropignore automatically on system start, follow the instructions below.

Adjust the paths to the dropignore binary and your Dropbox installation folder accordingly!

Linux with systemd

Create file ~/.config/systemd/user/dropignore.service with the following content:

[Unit]
Description=dropignore

[Service]
ExecStart=%h/.local/bin/dropignore watch %h/Dropbox
Restart=on-failure

[Install]
WantedBy=default.target

Now enable and load the unit:

$ systemctl --user daemon-reload
$ systemctl enable --now --user dropignore.service

# Check status
$ systemctl status --user dropignore.service

# For debugging
$ journalctl --user-unit dropignore.service --follow

macOs with launchd

Create file $HOME/Library/LaunchAgents/com.user.dropignore.plist with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.user.dropignore</string>
    <key>ProgramArguments</key>
    <array>
      <string>sh</string>
      <string>-c</string>
      <string>$HOME/bin/dropignore watch $HOME/Library/CloudStorage/Dropbox/</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
  </dict>
</plist>

Now enable and load the LaunchAgent:

$ launchctl load ~/Library/LaunchAgents/com.user.dropignore.plist

# Check status
$ launchctl list com.user.dropignore

# For debugging
$ log show --predicate 'eventMessage contains "com.user.dropignore"' --info --last 1h`

Notes and Limitations

  • use at your own risk - allthough no data deletion is performed, be warned.
  • only developed on Linux - untested by myself on Windows and macOS (except integration tests)
  • using .gitignore as the source of exclusion patterns is currently not considered
    • there might be projects shared in Dropbox which are actually neither version controlled nor programming related
    • someone might like to gitgnore any IDE specific files or folders, but still keep them synced over Dropbox
    • global gitignore settings would need to be considered/sourced then as well

Motivation

For years developers and artists use Dropbox to share projects. When working on these projects, build tools or other programs might create temporary output folders with a huge amount of files or size which shall not be synced to Dropbox.

The old trick for not syncing them was to delete any content in the folder which shall be ignored once, waiting for the sync to finish and then selectively ignore (unselect) this folder in the selective sync settings.

Whenever this folder was re-created or filled with new content locally it was kept ignored and not synced to your Dropbox account.

In late 2019 Dropbox decided to mess arround with the selective sync feature every creative got used to, ignoring files or folders got a mess.

Essentially the old trick didn't work anymore. Whenever an ignored folder was locally deleted and re-created - e.g. the target folder for Maven - the Dropbox client immedeately renamed the local folder to target (Selective Sync Conflict) - effectively moving your build artifacts to where they are not found anymore. Whenever the original folder got re-created another copy would be placed next to the previously renamed folder.

So you either don't use the selective sync feature anymore and live with the fact that syncing your temporary output folders might take ages and consume quite some space in your Dropbox or you go with the proposed solution to use extended file system attributes - with the circumstance that this solution does not work with re-created files or folders which are to be ignored as the attributes are gone after deletion.

So dropignore as a first-time Rust project for me came to be.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A tool to conveniently ignore files and folders from Dropbox sync.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages