Commit 683618cf authored by Tommaso Tocci's avatar Tommaso Tocci Committed by Marc Vef
Browse files

fix concurrent file removal

with the current storage back-end, chunks of a file are stored in
several files in a folder on a real kernel-space filesystem.

Removing a file means that we need to remove the entire directory and
all its sub-files (rm -r).
This operation is not atomic and it can raise errors if performed
concurrently..

This commit handles properly this kind of errors.
parent b5d85fc6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -28,7 +28,12 @@ int destroy_chunk_space(const std::string& path) {
    chnk_path /= fs_path;

    // remove chunk dir with all contents if path exists
    try {
        bfs::remove_all(chnk_path);
    } catch (const bfs::filesystem_error& e){
        ADAFS_DATA->spdlogger()->error("{}() Recursive remove failed; {}", __func__, e.what());
        return -1;
    }
    return 0;
}