Repository navigation
Remove unfinished ISO copies when the app starts - #124
Conversation
A copy writes <name>.iso.part and renames it when done. If the app is closed or crashes mid-copy the .part file stays, invisible in the app, taking GBs. removePartFiles deletes *.iso.part in the ISOs folder and skips anything it can't delete.
At startup no copy can be running, and the single instance lock keeps a second copy of the app from starting one, so .part files there are always leftovers.
A21-devs
left a comment
There was a problem hiding this comment.
Startup is the right place, and the try/catch per file means a locked file or a folder called x.iso.part can't stop the app from starting. One real problem with what gets matched, inline.
| return names.filter((f) => { | ||
| if (!f.toLowerCase().endsWith('.iso.part')) return false | ||
| try { | ||
| rmSync(join(isosDir, f)) |
There was a problem hiding this comment.
*.iso.part isn't only ours. Firefox downloads to <name>.iso.part next to the final file, and people do point downloads at the ISOs folder. Starting the app during a Firefox download of an ISO would delete the half-done download, and Firefox then fails it. Our copies should use a suffix nobody else uses (say .iso.vmm-copy), and this should only remove that one.
|
Good catch, fixed in 286e22d. Copies now write Leftover Reran typecheck, |
Firefox downloads to <name>.iso.part, so deleting *.iso.part at startup could kill a download in progress in the ISOs folder. Copies now write <name>.iso.vmm-copy and only that suffix is cleaned up. Renamed removePartFiles to removeUnfinishedCopies to match.
A21-devs
left a comment
There was a problem hiding this comment.
Checked 286e22d against the earlier comment. copyInto and the cleanup both use COPY_SUFFIX now, so the two can't drift apart, and the match is on .iso.vmm-copy lowercased, so a Firefox .iso.part (or anything else) is left alone. The test covers exactly that case. listIsos still only lists names ending in .iso, so an in-progress copy stays hidden from the ISO picker as before. Resolved.
Closes #54
Copying a dropped ISO into the ISOs folder writes
<name>.iso.partand renames it at the end (#52). If the app is closed or crashes in the middle, the.partfile stays. The app never lists it, so the only sign was GBs of disk space gone.removePartFiles(isosDir)in isos.ts deletes every*.iso.part(any case) in the ISOs folder and returns the names. Files it can't delete are skipped and tried again on the next start. Other files, including anotes.partthat isn't ours, are left alone.registerIpccalls it once at startup, before the folder watcher starts. No copy can be running then, and the single instance lock means a second copy of the app can't be in the middle of one either. What it removed goes to the console.Testing
npm run typecheck,npm test(142 passed),npm run buildtests/isos.test.ts: removesx (2).iso.partandBIG.ISO.PART, keepskali.isoandnotes.part, and copes with a missing folder.VMM_SMOKE=1) with a temp data folder holdingtest.iso.partandkeep.iso: loggedremoved unfinished ISO copies: test.iso.part, printed SMOKE OK,keep.isowas still there.