]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados_sync: add test for temp file deletion, fix
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 2 Jun 2011 23:59:51 +0000 (16:59 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 2 Jun 2011 23:59:51 +0000 (16:59 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/rados_sync.cc
src/test/test_rados_tool.sh

index e194adf70db4205d73c28483a4881b28f5adffd8..d24e12dcabb1f0103f50d917497aea1a13e0a709 100644 (file)
@@ -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 <BackedUpObject> lobj;
index 5d1687b4eb489a5e45542941ba5107bd380ef36e..c7c31c0dbc212f1742f09e60c2e35bb678378326 100755 (executable)
@@ -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