fix: Handle deletion of unsaved copied file in NotebookPanel#1557
fix: Handle deletion of unsaved copied file in NotebookPanel#1557mofojed merged 9 commits intodeephaven:mainfrom
Conversation
…o 1359-overflow-menu-options
…o 1359-overflow-menu-options
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1557 +/- ##
==========================================
- Coverage 46.36% 46.33% -0.03%
==========================================
Files 564 569 +5
Lines 35787 35925 +138
Branches 8959 9000 +41
==========================================
+ Hits 16591 16647 +56
- Misses 19144 19226 +82
Partials 52 52
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
mofojed
left a comment
There was a problem hiding this comment.
There's still a case that can result in lost data:
- Have a file named
foo.py - In File Explorer, right-click the file and select "Copy File". A new file
foo-copy.pyis created. - Open foo-copy.py, make some edits, then save and close it.
- Open the original
foo.pynotebook - From the notebook menu, choose "Copy File". It will open a new tab with the name
foo-copy.py, effectively masking the file from the same name already on disk. - From the new tab with the name
foo-copy.py, selectDelete File. It will delete thefoo-copy.pyfile from disk.
I think the fix for that is in handleCopy to loop when getting the copy file name until you know that file doesn't exist.
|
That wouldn't fix the problem since the act of copying the file doesn't save it (this was the behaviour before my change) so trying to copy the same file twice without saving either of them first will still have the same problem as neither of the copies exist in |
|
Right that's a good point; or you could copy it from the notebook panel, then copy it from the file explorer after. |
mofojed
left a comment
There was a problem hiding this comment.
Make sure we get @dsmmcken 's approval before merging, as this does change behaviour (since the file is created right on copy, instead of requiring an explicit save after). I think it's better overall (too many weird cases the other way).
fileExistsfunction toFileUtilsto handle this checkgetUniqueCopyFileNamefunction toFileUtilsNotebookPanelchanged from opening an unsaved copy of the file to duplicating the file inFileStoragefirstTesting Instructions: