Skip to content

Commit

Permalink
Merge pull request #47 from shjy25/master
Browse files Browse the repository at this point in the history
fix move operation
  • Loading branch information
liuyongqing authored Aug 2, 2022
2 parents 2bfe2e0 + 4a1e75e commit 774e9ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(cosfs, 1.0.19-beta)
AC_INIT(cosfs, 1.0.20)
AC_CONFIG_HEADER([config.h])

AC_CANONICAL_SYSTEM
Expand Down
2 changes: 1 addition & 1 deletion src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ static int rename_object(const char* from, const char* to)
}
s3_realpath = get_realpath(from);

meta["x-cos-copy-source"] = urlEncode(service_path + bucket + "-" + appid + get_realpath(s3_realpath.c_str()));
meta["x-cos-copy-source"] = urlEncode(service_path + bucket + "-" + appid + s3_realpath.c_str());
meta["Content-Type"] = S3fsCurl::LookupMimeType(string(to));
meta["x-cos-metadata-directive"] = "REPLACE";

Expand Down
38 changes: 38 additions & 0 deletions test/move_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import random
import shutil
import sys

mountpoint = sys.argv[1]

filename = "cosfs_test_%d" % random.randint(0, 1000000)
origin_file = mountpoint + filename

data = "hello"
# suppose the "multipart_size" is set to 1 MB.
data = '0' * (2 * 1024 * 1024 + 12)
f = open(origin_file, 'w')
f.write(data)
f.flush()

origin_files = os.listdir(mountpoint)
dest_path = os.getcwd() + "/"

for g in origin_files:
shutil.move(mountpoint + g, dest_path)

sz = os.stat(dest_path + g).st_size
os.remove(dest_path + g)
assert sz == len(data), "%d, %d"%(sz, len(data))


data = '0' * (5 * 1024 * 1024 * 1024 + 12)
f = open(origin_file, 'w')
f.write(data)
f.flush()
for g in origin_files:
shutil.move(mountpoint + g, dest_path)

sz = os.stat(dest_path + g).st_size
os.remove(dest_path + g)
assert sz == len(data), "%d, %d"%(sz, len(data))

0 comments on commit 774e9ae

Please sign in to comment.