unison icon indicating copy to clipboard operation
unison copied to clipboard

Add optional feature to prevent system sleep during operation

Open melyux opened this issue 4 years ago • 5 comments

Unison has a natural need to keep the Mac from sleeping while it's doing any active operation (Looking for changes, propagating changes). It should lodge a kernel assertion on macOS to do this whenever such an operation is going on, at least while using the UI app.

melyux avatar Oct 22 '20 05:10 melyux

I have rephrased this as an enhancement; it's certainly not a bug that unison doesn't do this now. Whether any particular person wants long-running processes to stop sleep is unclear. I am unaware of most things doing this (e.g. rsync) and thus it seems any such feature should be default off.

I don't think this is specific to macOS, and I don't see the link to the GUI, so I didn't set those labels.

gdt avatar Oct 22 '20 12:10 gdt

The link to the GUI is very strong. Because Unison has ventured into the Mac app territory, that comes with expectations of some abstraction away from the hardware. I wouldn’t expect the Unison command line program to do this, since you’re right that it’s not the norm for command line applications to do so (though it doesn’t mean improvement’s not possible). One can simply do a caffeinate since they’re on the command line anyway. But I would certainly expect a Mac app to take care of that for me, or else I’d be using the command line, so the default for the GUI should be on.

melyux avatar Oct 22 '20 14:10 melyux

Please add an an authoritative link that describes this norm, if you can.

I have adjusted lablels.

As usual, this issue awaits a pull request.

gdt avatar Oct 22 '20 17:10 gdt

An authoritative link would be the following examples from similar Mac apps that provide this feature, but even if they didn't, no need to limit oneself to what everyone else is doing instead of what's best for the user. When you start an on-demand file transfer process of any kind, I guarantee that everyone would expect it to finish before being interrupted by a time-based sleep delay.

CyberDuck

On by default and you can't even turn it off. Cyberduck

FileZilla

On by default. FileZilla

Transmission

On by default. transmission

NZBVortex

On by default, likely you can't even turn it off. NZBvortex

Finder

Always on. Finder

Safari Downloads

Always on. Safari

melyux avatar Oct 25 '20 03:10 melyux

Having read more about mac power management:

  • I don't see why this should be GUI only. If one is running a single sync, one can wrap with a stay-awake command. But CLI unison with repeat is really just like the GUI operationally.
  • This is not really about mac; it should apply to any system that has the concept of sleep and a way to ask not to sleep.

If you want to write the code, please structure it so that it is general enough in light of the above, even if there are implementations only for mac. What i mean is that it should be possible to add support for other systems that have similar concepts without reorganizing what you do, essentially having some sort of "take wake lock" and "release wake lock" procedures that call system-specific implementations, and some global configuration for "take wake lock during sync operations" preference (with the understanding that if there is no implementation for that, it just won't happen).

(I don't have this problem so I don't intend to work on it.)

gdt avatar Feb 05 '23 12:02 gdt