diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 8f1d2f0..db66f9a 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -1471,6 +1471,7 @@ static int rename_directory(const char* from, const char* to) // does a safe copy - copies first and then deletes old for(mn_cur = mn_head; mn_cur; mn_cur = mn_cur->next){ if(!mn_cur->is_dir){ + // TODO: call s3fs_rename instead? if(!nocopyapi && !norenameapi){ result = rename_object(mn_cur->old_path, mn_cur->new_path); }else{ @@ -1523,6 +1524,12 @@ static int s3fs_rename(const char* from, const char* to) return result; } + // flush pending writes if file is open + FdEntity *entity = FdManager::get()->ExistOpen(from); + if(entity != NULL){ + entity->Flush(true); + } + // files larger than 5GB must be modified via the multipart interface if(S_ISDIR(buf.st_mode)){ result = rename_directory(from, to); diff --git a/test/integration-test-main.sh b/test/integration-test-main.sh index 1fbaf9c..075a37a 100755 --- a/test/integration-test-main.sh +++ b/test/integration-test-main.sh @@ -500,8 +500,7 @@ function add_all_tests { add_tests test_chown add_tests test_list add_tests test_remove_nonempty_directory - # TODO: broken: https://github.com/s3fs-fuse/s3fs-fuse/issues/145 - #add_tests test_rename_before_close + add_tests test_rename_before_close add_tests test_multipart_upload add_tests test_multipart_copy add_tests test_special_characters