From 03e85bcbc12259a1ac451814b529e942bbbeffa0 Mon Sep 17 00:00:00 2001 From: kavinren Date: Wed, 27 Jul 2022 14:26:18 +0800 Subject: [PATCH 1/4] fix:fix move operation --- src/s3fs.cpp | 2 +- test/move_test.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/move_test.py diff --git a/src/s3fs.cpp b/src/s3fs.cpp index fff52f9..60b4e40 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -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"; diff --git a/test/move_test.py b/test/move_test.py new file mode 100644 index 0000000..427e881 --- /dev/null +++ b/test/move_test.py @@ -0,0 +1,11 @@ +import os +import shutil +import sys + +origin_path = sys.argv[1] +dest_path = sys.argv[2] + +origin_files = os.listdir(origin_path) + +for g in origin_files: + shutil.move(origin_path + g, dest_path) \ No newline at end of file From f7fd96487ff4790d749004643dca3ff53613343a Mon Sep 17 00:00:00 2001 From: kavinren Date: Wed, 27 Jul 2022 14:26:18 +0800 Subject: [PATCH 2/4] fix:fix move operation --- configure.ac | 2 +- src/s3fs.cpp | 2 +- test/move_test.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/move_test.py diff --git a/configure.ac b/configure.ac index 58ee59c..17aa62e 100644 --- a/configure.ac +++ b/configure.ac @@ -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-beta) AC_CONFIG_HEADER([config.h]) AC_CANONICAL_SYSTEM diff --git a/src/s3fs.cpp b/src/s3fs.cpp index fff52f9..60b4e40 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -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"; diff --git a/test/move_test.py b/test/move_test.py new file mode 100644 index 0000000..427e881 --- /dev/null +++ b/test/move_test.py @@ -0,0 +1,11 @@ +import os +import shutil +import sys + +origin_path = sys.argv[1] +dest_path = sys.argv[2] + +origin_files = os.listdir(origin_path) + +for g in origin_files: + shutil.move(origin_path + g, dest_path) \ No newline at end of file From eb8c23cd51e5ceff81cb081ad1abf5f6ae64ac53 Mon Sep 17 00:00:00 2001 From: kavinren Date: Wed, 27 Jul 2022 15:25:53 +0800 Subject: [PATCH 3/4] update version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 17aa62e..93fb370 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(cosfs, 1.0.20-beta) +AC_INIT(cosfs, 1.0.20) AC_CONFIG_HEADER([config.h]) AC_CANONICAL_SYSTEM From 4a1e75edf735b31ef9b8014484877ea7ddf23625 Mon Sep 17 00:00:00 2001 From: kavinren Date: Wed, 27 Jul 2022 17:01:48 +0800 Subject: [PATCH 4/4] update move test --- test/move_test.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/test/move_test.py b/test/move_test.py index 427e881..5db913e 100644 --- a/test/move_test.py +++ b/test/move_test.py @@ -1,11 +1,38 @@ import os +import random import shutil import sys -origin_path = sys.argv[1] -dest_path = sys.argv[2] +mountpoint = sys.argv[1] -origin_files = os.listdir(origin_path) +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(origin_path + g, dest_path) \ No newline at end of file + 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)) \ No newline at end of file