Skip to content

Keep a video's Copy in the cache and only export it once - #56

Merged
faetalize merged 11 commits into
masterfrom
fix/49-52-video-copy-cache
Nov 1, 2026
Merged

faetalize merged 11 commits into
masterfrom
fix/49-52-video-copy-cache

Conversation

@faetalize

@faetalize faetalize commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Copying a video now exports it once. Copying it again puts the same file back on the clipboard straight away, until the edit or the Copy profile changes or the file is gone.

Copied videos no longer pile up in the Videos folder. Each one is kept in ~/.cache/waytator/copies under a clean name and deleted about a week after it was last copied. Export is the way to keep a video.

Copy no longer counts as saving a video, so closing the window afterwards asks before throwing the edit away. Close on Copy still closes straight away.

Save, copy and close on a video now asks where to export it, then copies that file and closes.

Closing a video while it exports asks first, and closing it stops the export.

Sandboxed apps that can't read that folder can't paste videos copied with Copy.

Closes #49
Closes #52

Copy now exports into a folder of its own under ~/.cache/waytator/copies,
so the pasted file keeps a clean name and nothing piles up in ~/Videos.
It goes on disk rather than in the runtime folder because an export can
be bigger than memory.

Copy remembers the file it made with the edit and profile behind it, and
puts that file back on the clipboard while they match and it still
exists. Edits are compared by value, so undoing back to where the file
was made reuses it and undoing past it doesn't. Profiles are compared by
their settings, since one edited in the preferences keeps its id. The
memory goes when the video closes: the same edits on another video, or
on this one once it is replaced, come out differently.

A reused file counts as saved like an export does, or a window closing
on Copy could stop to ask about edits made since.

Copies are deleted a week after they were made or last copied, not when
the clipboard changes, because a clipboard manager keeps the link in its
history. That is judged by age rather than by the lock the rest of the
cache uses, as nothing that runs holds a copy. The sweep runs on its own
thread at startup and again on each video opened, since a background
service can run for weeks.

Closes #49
Closes #52
The shortcut was the same as Copy followed by closing, so for a video
nothing was saved. With Copy's file now in the cache, the only thing left
of the edit would have been deleted a week later. It now asks where to
export like Save and close does, puts that file on the clipboard and
closes. Backing out of a dialog does none of that.

What each button and shortcut does now comes from one plain function,
waytator_video_save_plan, so it can be tested without a window. The
window has no other copy of those decisions: the booleans it used to be
called with are gone.
An edit counted as saved once any export finished, which made sense when
Copy left a lasting file in the Videos folder. Copy's file now gets
deleted after a week, so after a Copy with the window left open, closing
threw the edit away without the usual question.

Saved now means a lasting file has the edit. Whether a button or shortcut
does that comes from the save plan, and the export it runs follows from
it, so Copy and a reused Copy leave the edit unsaved.

Closing on Copy doesn't set the flag either: it goes the way Discard does
once the copy has worked. Marking the edit saved instead would be wrong
when wl-copy fails, as the window stays open with an edit that only looks
safe to close. An edit made while the copy exported still gets the
question, since the file doesn't have it.
An export carried on after its window closed, even once its edit was
discarded. It could still replace the original or take over the clipboard
with a window nobody was looking at, and a background service kept the
process around for it to finish.

Closing a video now cancels its export. The window does that from the
application's window-removed signal rather than dispose or close-request:
a running export holds the window, so dispose wouldn't come until it was
done, and close-request misses windows destroyed directly. The window
also counts as gone from that point, so an export that finished just
before the cancel reached it doesn't copy either.
Reusing a copy checked the file was there and then started its week over,
ignoring whether that worked. A sweep landing in between left the clipboard
with a link to nothing behind a success tick.

The date now comes first, so a later sweep leaves the file alone, and the
file is looked for after it, so an earlier one is noticed. If the date
can't be set the copy is exported again. The steps live in
waytator_video_copy_reuse, which the editor calls, so they can be tested
without a window.
Copies were only swept at startup and when a video opened, so a background
service used for screenshots never deleted any. The sweep now runs at
startup and once a day from there, in one place rather than two. That means
a copy goes within a day of its week being up, so the README says about a
week.
A video opened from where its copy is kept could be deleted by a sweep once
it passed its week, and the decoder reopens the file, so playback and export
then failed with the edit stuck in the window. Refreshing the folder's date
on opening would only put that off, so the editor holds a lock on the
folder for as long as the video is open, the way the rest of the cache
keeps sweeps off files in use, and the sweep skips what is held.
Save, copy and close skips opening the export because the window is about
to close. When wl-copy then failed the window stayed open on a file the
export had already replaced, so the next save made the same edits again,
or failed if the format had changed and the original was gone. A failed copy
now does the opening the export skipped.
Closing a window stops its export, and with nothing unsaved that happened
without a word, so a long export could go with one click. Closing now asks
whenever an export is running, Copy's included, as it counts as something
to lose everywhere else too.

The question is about closing, since that is what was asked for, and its
body says what goes with it. Both offer to keep exporting rather than
editing: an edit made during an export isn't in it. What to ask comes from
one plain function, so it can be tested without a window.
@faetalize
faetalize merged commit 355b5f7 into master Nov 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

copying a video multiple times video export as copy inconsistency.

1 participant