mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-03 13:07:24 +00:00
Fix for issue #145 and additional tests in make check
git-svn-id: http://s3fs.googlecode.com/svn/trunk@301 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
3d9c255ba2
commit
0f18298886
23
src/s3fs.cpp
23
src/s3fs.cpp
@ -1748,7 +1748,7 @@ static int put_local_fd_big_file(const char* path, headers_t meta, int fd) {
|
|||||||
// printf("got curl handle\n");
|
// printf("got curl handle\n");
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
|
// curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&body);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&body);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *)&header);
|
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *)&header);
|
||||||
@ -1884,7 +1884,7 @@ static int put_local_fd_big_file(const char* path, headers_t meta, int fd) {
|
|||||||
curl = create_curl_handle();
|
curl = create_curl_handle();
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
|
// curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&body);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&body);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, true);
|
curl_easy_setopt(curl, CURLOPT_POST, true);
|
||||||
@ -3042,6 +3042,16 @@ static int s3fs_open(const char *path, struct fuse_file_info *fi) {
|
|||||||
cout << "open[path=" << path << "][flags=" << fi->flags << "]" << endl;
|
cout << "open[path=" << path << "][flags=" << fi->flags << "]" << endl;
|
||||||
|
|
||||||
headers_t meta;
|
headers_t meta;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
// Go do the truncation if called for
|
||||||
|
if ((unsigned int)fi->flags & O_TRUNC) {
|
||||||
|
result = s3fs_truncate(path, 0);
|
||||||
|
if (result != 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//###TODO check fi->fh here...
|
//###TODO check fi->fh here...
|
||||||
fi->fh = get_local_fd(path);
|
fi->fh = get_local_fd(path);
|
||||||
|
|
||||||
@ -3510,6 +3520,13 @@ static void* s3fs_init(struct fuse_conn_info *conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Investigate system capabilities
|
||||||
|
if ( (unsigned int)conn->capable & FUSE_CAP_ATOMIC_O_TRUNC) {
|
||||||
|
// so let's set the bit
|
||||||
|
conn->want |= FUSE_CAP_ATOMIC_O_TRUNC;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3633,7 +3650,7 @@ static int list_multipart_uploads(void) {
|
|||||||
curl = create_curl_handle();
|
curl = create_curl_handle();
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
|
// curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&body);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&body);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ source $REQUIRE_ROOT
|
|||||||
# Configuration
|
# Configuration
|
||||||
TEST_TEXT="HELLO WORLD"
|
TEST_TEXT="HELLO WORLD"
|
||||||
TEST_TEXT_FILE=test-s3fs.txt
|
TEST_TEXT_FILE=test-s3fs.txt
|
||||||
|
TEST_DIR=testdir
|
||||||
ALT_TEST_TEXT_FILE=test-s3fs-ALT.txt
|
ALT_TEST_TEXT_FILE=test-s3fs-ALT.txt
|
||||||
TEST_TEXT_FILE_LENGTH=15
|
TEST_TEXT_FILE_LENGTH=15
|
||||||
|
|
||||||
@ -103,6 +104,85 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# test redirects > and >>
|
||||||
|
###################################################################
|
||||||
|
echo "Testing redirects ..."
|
||||||
|
|
||||||
|
echo ABCDEF > $TEST_TEXT_FILE
|
||||||
|
if [ ! -e $TEST_TEXT_FILE ]
|
||||||
|
then
|
||||||
|
echo "Could not create file ${TEST_TEXT_FILE}, it does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONTENT=`cat $TEST_TEXT_FILE`
|
||||||
|
|
||||||
|
if [ ${CONTENT} != "ABCDEF" ]; then
|
||||||
|
echo "CONTENT read is unexpected, got ${CONTENT}, expected ABCDEF"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo XYZ > $TEST_TEXT_FILE
|
||||||
|
|
||||||
|
CONTENT=`cat $TEST_TEXT_FILE`
|
||||||
|
|
||||||
|
if [ ${CONTENT} != "XYZ" ]; then
|
||||||
|
echo "CONTENT read is unexpected, got ${CONTENT}, expected XYZ"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 123456 >> $TEST_TEXT_FILE
|
||||||
|
|
||||||
|
LINE1=`sed -n '1,1p' $TEST_TEXT_FILE`
|
||||||
|
LINE2=`sed -n '2,2p' $TEST_TEXT_FILE`
|
||||||
|
|
||||||
|
if [ ${LINE1} != "XYZ" ]; then
|
||||||
|
echo "LINE1 was not as expected, got ${LINE1}, expected XYZ"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${LINE2} != "123456" ]; then
|
||||||
|
echo "LINE2 was not as expected, got ${LINE2}, expected 123456"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# clean up
|
||||||
|
rm $TEST_TEXT_FILE
|
||||||
|
|
||||||
|
if [ -e $TEST_TEXT_FILE ]
|
||||||
|
then
|
||||||
|
echo "Could not cleanup file ${TEST_TEXT_FILE}, it still exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# Simple directory test mkdir/rmdir
|
||||||
|
#####################################################################
|
||||||
|
echo "Testing creation/removal of a directory"
|
||||||
|
|
||||||
|
if [ -e $TEST_DIR ]; then
|
||||||
|
echo "Unexpected, this file/directory exists: ${TEST_DIR}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir ${TEST_DIR}
|
||||||
|
|
||||||
|
if [ ! -d ${TEST_DIR} ]; then
|
||||||
|
echo "Directory ${TEST_DIR} was not created"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmdir ${TEST_DIR}
|
||||||
|
if [ -e $TEST_DIR ]; then
|
||||||
|
echo "Could not remove the test directory, it still exists: ${TEST_DIR}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# Tests are finished
|
# Tests are finished
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user