webtorrent / webtorrent-desktop

❤️ Streaming torrent app for Mac, Windows, and Linux
https://webtorrent.io/desktop
MIT License
9.62k stars 997 forks source link

config init: unlink files before copying over #2389

Closed bendlas closed 3 months ago

bendlas commented 8 months ago

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update [x] Bug fix [ ] New feature [ ] Other, please explain:

What changes did you make? (Give an overview)

When:

Error:

Missing config file: Creating new one
(node:679284) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, copyfile '/home/user/code/webtorrent-desktop/static/bigBuckBunny.jpg' -> '/home/user/.config/WebTorrent/Posters/88594aaacbde40ef3e2510c47374ec0aa396c08e.jpg'
    at copyFileSync (node:fs:2894:3)
    at func (node:electron/js2c/asar_bundle:2:2131)
    at overwriteSync (/home/user/code/webtorrent-desktop/src/renderer/lib/state.js:125:3)
    at /home/user/code/webtorrent-desktop/src/renderer/lib/state.js:158:5
    at Array.forEach (<anonymous>)
    at setupStateSaved (/home/user/code/webtorrent-desktop/src/renderer/lib/state.js:155:27)
    at EventEmitter.load (/home/user/code/webtorrent-desktop/src/renderer/lib/state.js:230:15)

I wish I could explain why this happens, but neither ls nor lsattr shows anything:

% ls -alh ~/.config/WebTorrent/Posters
Missing config file: Creating new one
(node:679284) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, copyfile '/home/user/code/webtorrent-desktop/static/bigBuckBunny.jpg' -> '/home/user/.config/WebTorrent/Posters/88594aaacbde40ef3e2510c47374ec0aa396c08e.jpg'
    at copyFileSync (node:fs:2894:3)
    at func (node:electron/js2c/asar_bundle:2:2131)
    at overwriteSync (/home/user/code/webtorrent-desktop/src/renderer/lib/state.js:125:3)
    at /home/user/code/webtorrent-desktop/src/renderer/lib/state.js:158:5
    at Array.forEach (<anonymous>)
    at setupStateSaved (/home/user/code/webtorrent-desktop/src/renderer/lib/state.js:155:27)
    at EventEmitter.load (/home/user/code/webtorrent-desktop/src/renderer/lib/state.js:230:15)
% lsattr -a ~/.config/WebTorrent/Posters
---------------------- /home/user/.config/WebTorrent/Posters/.
---------------------- /home/user/.config/WebTorrent/Posters/..
---------------------- /home/user/.config/WebTorrent/Posters/02767050e0be2fd4db9a2ad6c12416ac806ed6ed.jpg
---------------------- /home/user/.config/WebTorrent/Posters/6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5.jpg
---------------------- /home/user/.config/WebTorrent/Posters/a88fda5954e89178c372716a6a78b8180ed4dad3.jpg
---------------------- /home/user/.config/WebTorrent/Posters/88594aaacbde40ef3e2510c47374ec0aa396c08e.jpg
---------------------- /home/user/.config/WebTorrent/Posters/6a9759bffd5c0af65319979fb7832189f4f3c35d.jpg

The workaround fixes it though.

Which issue (if any) does this pull request address?

Is there anything you'd like reviewers to focus on?

github-actions[bot] commented 6 months ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

bendlas commented 6 months ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

Still relevant. Only thing blocking this is lack of reviews.

github-actions[bot] commented 4 months ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

bendlas commented 2 weeks ago

@gillesdemey @rom1504 I think we should also have this in. It has finally fixed the nagging heisenbug, where webtorrent-desktop randomly stops starting up. As with https://github.com/webtorrent/webtorrent-desktop/pull/2388, we've been shipping this in NixOS for some time now.

If you think it would be worth, please re-open. I'll be happy to rebase.