mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-19 02:35:13 +00:00
Merge pull request #403 from rockuw/master
Fix a bug of truncating empty file
This commit is contained in:
commit
72f6c4d2dc
@ -2595,7 +2595,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_
|
|||||||
{
|
{
|
||||||
S3FS_PRN_INFO3("[tpath=%s][start=%jd][size=%zd]", SAFESTRPTR(tpath), (intmax_t)start, size);
|
S3FS_PRN_INFO3("[tpath=%s][start=%jd][size=%zd]", SAFESTRPTR(tpath), (intmax_t)start, size);
|
||||||
|
|
||||||
if(!tpath || -1 == fd || 0 > start || 0 >= size){
|
if(!tpath || -1 == fd || 0 > start || 0 > size){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2611,7 +2611,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_
|
|||||||
requestHeaders = NULL;
|
requestHeaders = NULL;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
if(-1 != start && -1 != size){
|
if(-1 != start && 0 < size){
|
||||||
string range = "bytes=";
|
string range = "bytes=";
|
||||||
range += str(start);
|
range += str(start);
|
||||||
range += "-";
|
range += "-";
|
||||||
|
@ -41,6 +41,24 @@ function test_truncate_file {
|
|||||||
rm_test_file
|
rm_test_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_truncate_empty_file {
|
||||||
|
echo "Testing truncate empty file ..."
|
||||||
|
# Write an empty test file
|
||||||
|
touch ${TEST_TEXT_FILE}
|
||||||
|
|
||||||
|
# Truncate the file to 1024 length
|
||||||
|
t_size=1024
|
||||||
|
truncate ${TEST_TEXT_FILE} -s $t_size
|
||||||
|
|
||||||
|
# Verify file is zero length
|
||||||
|
size=$(stat -c %s ${TEST_TEXT_FILE})
|
||||||
|
if [ $t_size -ne $size ]
|
||||||
|
then
|
||||||
|
echo "error: expected ${TEST_TEXT_FILE} to be $t_size length, got $size"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
rm_test_file
|
||||||
|
}
|
||||||
|
|
||||||
function test_mv_file {
|
function test_mv_file {
|
||||||
describe "Testing mv file function ..."
|
describe "Testing mv file function ..."
|
||||||
@ -377,6 +395,7 @@ function test_write_after_seek_ahead {
|
|||||||
function add_all_tests {
|
function add_all_tests {
|
||||||
add_tests test_append_file
|
add_tests test_append_file
|
||||||
add_tests test_truncate_file
|
add_tests test_truncate_file
|
||||||
|
add_tests test_truncate_empty_file
|
||||||
add_tests test_mv_file
|
add_tests test_mv_file
|
||||||
add_tests test_mv_directory
|
add_tests test_mv_directory
|
||||||
add_tests test_redirects
|
add_tests test_redirects
|
||||||
|
Loading…
Reference in New Issue
Block a user