From 637dfc3ed3194fdb1f5235cd48c8023c7fb1cbda Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 2 Jun 2011 16:59:51 -0700 Subject: [PATCH] rados_sync: add test for temp file deletion, fix Signed-off-by: Colin McCabe --- src/rados_sync.cc | 3 ++- src/test/test_rados_tool.sh | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rados_sync.cc b/src/rados_sync.cc index e194adf70db42..d24e12dcabb1f 100644 --- a/src/rados_sync.cc +++ b/src/rados_sync.cc @@ -865,13 +865,14 @@ static int do_export(IoCtx& io_ctx, const char *dir_name, continue; if (is_suffix(de->d_name, RADOS_SYNC_TMP_SUFFIX)) { char path[strlen(dir_name) + strlen(de->d_name) + 2]; - snprintf("%s/%s", sizeof(path), dir_name, de->d_name); + snprintf(path, sizeof(path), "%s/%s", dir_name, de->d_name); if (unlink(path)) { ret = errno; cerr << ERR_PREFIX << "error unlinking temporary file '" << path << "': " << cpp_strerror(ret) << std::endl; return ret; } + cout << "[deleted] " << "removed temporary file '" << de->d_name << "'" << std::endl; continue; } auto_ptr lobj; diff --git a/src/test/test_rados_tool.sh b/src/test/test_rados_tool.sh index 5d1687b4eb489..c7c31c0dbc212 100755 --- a/src/test/test_rados_tool.sh +++ b/src/test/test_rados_tool.sh @@ -141,5 +141,10 @@ run_expect_succ grep '\[exported\]' "$TDIR/out6" diff -q -r "$TDIR/dird" "$TDIR/dire" \ || die "failed to export the same stuff we imported!" +# create a temporary file and validate that export deletes it +touch "$TDIR/dire/tmp\$tmp" +run_expect_succ "$RADOS_TOOL" --delete-after --create export "$POOL" "$TDIR/dire" | tee "$TDIR/out7" +run_expect_succ grep temporary "$TDIR/out7" + echo "SUCCESS!" exit 0 -- 2.39.5