RESOLVED FIXED225289
Restore pre-r276879 behavior for FileSystem::deleteFile() and FileSystem::deleteEmptyDirectory()
https://bugs.webkit.org/show_bug.cgi?id=225289
Summary Restore pre-r276879 behavior for FileSystem::deleteFile() and FileSystem::del...
Chris Dumez
Reported 2021-05-02 19:22:33 PDT
Restore pre-r276879 behavior for FileSystem::deleteFile() and FileSystem::deleteEmptyDirectory().
Attachments
Patch (14.04 KB, patch)
2021-05-02 19:32 PDT, Chris Dumez
no flags
Patch (14.09 KB, patch)
2021-05-03 08:03 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2021-05-02 19:32:06 PDT
Chris Dumez
Comment 2 2021-05-03 08:03:46 PDT
Darin Adler
Comment 3 2021-05-03 10:02:25 PDT
Comment on attachment 427558 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427558&action=review > Source/WTF/wtf/FileSystem.cpp:493 > bool deleteFile(const String& path) Maybe later we want to add a new call that matches more directly what std::filesystem::remove does, and remove these? I don’t think all callers *need* to do the "only do it if it’s a file/directory" version; it’s just that before we were starting by mirroring that feature of the POSIX API where unlink is for files only and rmdir is for directories only. Now we are in a funny place where we are more work for a semantic callers might not need. > Source/WTF/wtf/FileSystem.cpp:506 > bool deleteEmptyDirectory(const String& path) Given the complexity of all the ".DS_Store" stuff on Mac, maybe we should consider eventually getting rid of deleteEmptyDirectory to instead use a function that can delete even non-empty ones. I suppose it’s a safety measure to prevent deleting a lot of files that we use deleteEmptyDirectory.
Chris Dumez
Comment 4 2021-05-03 10:07:01 PDT
(In reply to Darin Adler from comment #3) > Comment on attachment 427558 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=427558&action=review > > > Source/WTF/wtf/FileSystem.cpp:493 > > bool deleteFile(const String& path) > > Maybe later we want to add a new call that matches more directly what > std::filesystem::remove does, and remove these? I don’t think all callers > *need* to do the "only do it if it’s a file/directory" version; it’s just > that before we were starting by mirroring that feature of the POSIX API > where unlink is for files only and rmdir is for directories only. Now we are > in a funny place where we are more work for a semantic callers might not > need. Yes, I agree. I will look into this. For now, I figure the safest choice is to maintain pre-existing behavior until I can check all call sites. > > > Source/WTF/wtf/FileSystem.cpp:506 > > bool deleteEmptyDirectory(const String& path) > > Given the complexity of all the ".DS_Store" stuff on Mac, maybe we should > consider eventually getting rid of deleteEmptyDirectory to instead use a > function that can delete even non-empty ones. I suppose it’s a safety > measure to prevent deleting a lot of files that we use deleteEmptyDirectory. I think we view deleteEmptyDirectory() as a way to avoid deleting non-webkit files in webkit folders. For example, I have a database IndexedDB.db in a IndexedDB/ folder and I want to remove the database. We usually call removeFile(IndexedDB.db) to remove our database, then deleteEmptyDirectory("IndexedDB/") to remove the folder but only if there is nothing else in it. I guess one worry is that the user might put a file in that WebKit directory and we wouldn't want to delete it. It seems unlikely to happen in practice but we try to stay on the safe side.
EWS
Comment 5 2021-05-03 10:23:35 PDT
Committed r276906 (237251@main): <https://commits.webkit.org/237251@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427558 [details].
Radar WebKit Bug Importer
Comment 6 2021-05-03 10:24:18 PDT
Note You need to log in before you can comment on or make changes to this bug.