Repository navigation
Automatically remove old persistent cache dir - #18244
Conversation
a99de4d to
533b5f3
Compare
|
|
||
| } // namespace fml | ||
|
|
||
| void fml::RemoveFilesInDirectory(const fml::UniqueFD& directory) { |
There was a problem hiding this comment.
Move this inside the namespace fml block
| auto dir = fml::OpenDirectory(directory, filename.c_str(), false, | ||
| fml::FilePermission::kReadWrite); | ||
| if (dir.is_valid()) { | ||
| fml::RemoveFilesInDirectory(dir); |
There was a problem hiding this comment.
It would be simpler to have the directory tree delete function take a parent UniqueFD and the name of the directory to delete (similar to fml::UnlinkDirectory, but recursive).
With that change the delete function can unlink the directory itself after all the contents have been removed.
There was a problem hiding this comment.
Done with RemoveDirectoryRecursively added. The old RemoveFilesInDirectory is still preserved for unit tests (e.g., https://github.com/flutter/engine/pull/18244/files#diff-b3bfc82230a960f6d96fe512bacd4d7cR235)
| TEST_F(ShellTest, CanRemoveOldPersistentCache) { | ||
| fml::ScopedTemporaryDirectory base_dir; | ||
|
|
||
| fml::CreateDirectory(base_dir.fd(), |
There was a problem hiding this comment.
Assert that you actually got the FD here.
|
|
||
| } // namespace fml | ||
|
|
||
| void fml::RemoveFilesInDirectory(const fml::UniqueFD& directory) { |
There was a problem hiding this comment.
Please put this in the FML namespace block.
|
|
||
| /// Helper method to recursively remove files and subdirectories inside the | ||
| /// directory. The directory itself will not be removed. | ||
| void RemoveFilesInDirectory(const fml::UniqueFD& directory); |
There was a problem hiding this comment.
Some error handling would be good here. Return a bool to notify that the files were actually deleted maybe. Right now, failures are silent.
551566a to
8382c33
Compare
|
Merge as the retry https://ci.chromium.org/p/flutter/builders/try/Mac%20Android%20Debug%20Engine/2499 passed. |
Fixes flutter/flutter#53445
I was just notified today that there's a deadline of fixing this before 5/14/2020.