menu

Mutagen

Mutagen makes remote development work with your local tools

Channels
Team

Avoiding staging moves

September 27, 2019 at 2:22pm

Avoiding staging moves

September 27, 2019 at 2:22pm (Edited 2 months ago)
I'd just like to confirm that it's not configurable to not use a stager to write files, instead writing to files directly on change. Is that right?
A project I use on the remote host to watch for changes to files ignores file added and moved_to events; only file modifications trigger the desired behavior (which never happens with Mutagen). Mutegen's staging strategy is a good and correct one. I'm just looking into the possibility of a quick workaround.

September 27, 2019 at 2:23pm
For reference, this is related to guard/guard#924.
  • reply
  • like

September 28, 2019 at 2:20am
That's correct, only rename-based file placement is supported at the moment. There was an issue opened recently requesting support for in-place modifications, which I think does make sense (especially for very large files), but I don't have a precise timeline or plan for implementing it. Unfortunately it has more complex failure modes that need to be handled when tracking content changes and there's a risk of file corruption. Regarding this specific issue, one thing Mutagen could potentially do (on an opt-in basis) is update the modification time of a file after swapping it into place. Can you check (with something like touch <filename>) if Guard's watcher picks up on modification time changes?
  • reply
  • like
One additional follow-up thought: since Guard is probably using inotify-based watches on files, the modification time hack might not cause changes to be picked up. Or maybe the modification time would need to be triggered on the parent directory where the watch would remain stable. I'm not sure exactly... it depends on how Guard's watching is implemented. It could be more accurately tested with a mv <mock-staged-path> <destination-path> && touch <destination-path>
  • reply
  • like
Excellent idea. I know that touching the file on the destination server does indeed trigger guard to run. I can test the move+touch combo on Monday. Thanks!
  • reply
  • like
Cool, let me know exactly what sort of changes it detects with the move+touch. It shouldn't be too expensive in terms of performance, though I'd still probably make it an opt-in feature.
like-fill
1
  • reply
  • like

October 11, 2019 at 5:00am
Sorry for the delay! I confirmed that moving a file into place does not trigger guard, but touching the file immediately afterward does.
I attempted a spike (https://github.com/mutagen-io/mutagen/pull/158) to see if I could get your idea working, but I was unsuccessful. Let me know if you have ideas on what might be wrong.
  • reply
  • like