mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Add stat helper for user and group (#2320)
This commit is contained in:
parent
61df7bf42c
commit
ffff26e165
@ -320,11 +320,7 @@ function test_chown {
|
|||||||
mk_test_file
|
mk_test_file
|
||||||
|
|
||||||
local ORIGINAL_PERMISSIONS
|
local ORIGINAL_PERMISSIONS
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
ORIGINAL_PERMISSIONS=$(get_user_and_group "${TEST_TEXT_FILE}")
|
||||||
ORIGINAL_PERMISSIONS=$(stat -f "%u:%g" "${TEST_TEXT_FILE}")
|
|
||||||
else
|
|
||||||
ORIGINAL_PERMISSIONS=$(stat --format=%u:%g "${TEST_TEXT_FILE}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# [NOTE]
|
# [NOTE]
|
||||||
# Prevents test interruptions due to permission errors, etc.
|
# Prevents test interruptions due to permission errors, etc.
|
||||||
@ -337,12 +333,7 @@ function test_chown {
|
|||||||
|
|
||||||
# if they're the same, we have a problem.
|
# if they're the same, we have a problem.
|
||||||
local CHANGED_PERMISSIONS
|
local CHANGED_PERMISSIONS
|
||||||
# TODO: add helper
|
CHANGED_PERMISSIONS=$(get_user_and_group "${TEST_TEXT_FILE}")
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
|
||||||
CHANGED_PERMISSIONS=$(stat -f "%u:%g" "${TEST_TEXT_FILE}")
|
|
||||||
else
|
|
||||||
CHANGED_PERMISSIONS=$(stat --format=%u:%g "${TEST_TEXT_FILE}")
|
|
||||||
fi
|
|
||||||
if [ "${CHANGED_PERMISSIONS}" = "${ORIGINAL_PERMISSIONS}" ]
|
if [ "${CHANGED_PERMISSIONS}" = "${ORIGINAL_PERMISSIONS}" ]
|
||||||
then
|
then
|
||||||
if [ "${ORIGINAL_PERMISSIONS}" = "1000:1000" ]
|
if [ "${ORIGINAL_PERMISSIONS}" = "1000:1000" ]
|
||||||
@ -651,6 +642,7 @@ function test_multipart_copy {
|
|||||||
function test_multipart_mix {
|
function test_multipart_mix {
|
||||||
describe "Testing multi-part mix ..."
|
describe "Testing multi-part mix ..."
|
||||||
|
|
||||||
|
# TODO: why is this necessary?
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
cat /dev/null > "${BIG_FILE}"
|
cat /dev/null > "${BIG_FILE}"
|
||||||
fi
|
fi
|
||||||
@ -2175,11 +2167,7 @@ function test_ensurespace_move_file() {
|
|||||||
# Backup file stat
|
# Backup file stat
|
||||||
#
|
#
|
||||||
local ORIGINAL_PERMISSIONS
|
local ORIGINAL_PERMISSIONS
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
ORIGINAL_PERMISSIONS=$(get_user_and_group "${CACHE_DIR}/.s3fs_test_tmpdir/${BIG_FILE}")
|
||||||
ORIGINAL_PERMISSIONS=$(stat -f "%u:%g" "${CACHE_DIR}/.s3fs_test_tmpdir/${BIG_FILE}")
|
|
||||||
else
|
|
||||||
ORIGINAL_PERMISSIONS=$(stat --format=%u:%g "${CACHE_DIR}/.s3fs_test_tmpdir/${BIG_FILE}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fill the disk size
|
# Fill the disk size
|
||||||
@ -2205,11 +2193,7 @@ function test_ensurespace_move_file() {
|
|||||||
# file stat
|
# file stat
|
||||||
#
|
#
|
||||||
local MOVED_PERMISSIONS
|
local MOVED_PERMISSIONS
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
MOVED_PERMISSIONS=$(get_user_and_group "${BIG_FILE}")
|
||||||
MOVED_PERMISSIONS=$(stat -f "%u:%g" "${BIG_FILE}")
|
|
||||||
else
|
|
||||||
MOVED_PERMISSIONS=$(stat --format=%u:%g "${BIG_FILE}")
|
|
||||||
fi
|
|
||||||
local MOVED_FILE_LENGTH
|
local MOVED_FILE_LENGTH
|
||||||
MOVED_FILE_LENGTH=$(get_size "${BIG_FILE}")
|
MOVED_FILE_LENGTH=$(get_size "${BIG_FILE}")
|
||||||
|
|
||||||
@ -2547,11 +2531,7 @@ function test_chown_mountpoint {
|
|||||||
local MOUNTPOINT_DIR; MOUNTPOINT_DIR=$(cd ..; pwd)
|
local MOUNTPOINT_DIR; MOUNTPOINT_DIR=$(cd ..; pwd)
|
||||||
|
|
||||||
local ORIGINAL_PERMISSIONS
|
local ORIGINAL_PERMISSIONS
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
ORIGINAL_PERMISSIONS=$(get_user_and_group "${MOUNTPOINT_DIR}")
|
||||||
ORIGINAL_PERMISSIONS=$(stat -f "%u:%g" "${MOUNTPOINT_DIR}")
|
|
||||||
else
|
|
||||||
ORIGINAL_PERMISSIONS=$(stat --format=%u:%g "${MOUNTPOINT_DIR}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# [NOTE]
|
# [NOTE]
|
||||||
# Prevents test interruptions due to permission errors, etc.
|
# Prevents test interruptions due to permission errors, etc.
|
||||||
@ -2563,11 +2543,7 @@ function test_chown_mountpoint {
|
|||||||
|
|
||||||
# if they're the same, we have a problem.
|
# if they're the same, we have a problem.
|
||||||
local CHANGED_PERMISSIONS
|
local CHANGED_PERMISSIONS
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
CHANGED_PERMISSIONS=$(get_user_and_group "${MOUNTPOINT_DIR}")
|
||||||
CHANGED_PERMISSIONS=$(stat -f "%u:%g" "${MOUNTPOINT_DIR}")
|
|
||||||
else
|
|
||||||
CHANGED_PERMISSIONS=$(stat --format=%u:%g "${MOUNTPOINT_DIR}")
|
|
||||||
fi
|
|
||||||
if [ "${CHANGED_PERMISSIONS}" = "${ORIGINAL_PERMISSIONS}" ]
|
if [ "${CHANGED_PERMISSIONS}" = "${ORIGINAL_PERMISSIONS}" ]
|
||||||
then
|
then
|
||||||
if [ "${ORIGINAL_PERMISSIONS}" = "1000:1000" ]
|
if [ "${ORIGINAL_PERMISSIONS}" = "1000:1000" ]
|
||||||
|
@ -331,6 +331,14 @@ function get_permissions() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_user_and_group() {
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
stat -f "%u:%g" "$1"
|
||||||
|
else
|
||||||
|
"${STAT_BIN[@]}" --format "%u:%g" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function check_content_type() {
|
function check_content_type() {
|
||||||
local INFO_STR
|
local INFO_STR
|
||||||
INFO_STR=$(aws_cli s3api head-object --bucket "${TEST_BUCKET_1}" --key "$1" | jq -r .ContentType)
|
INFO_STR=$(aws_cli s3api head-object --bucket "${TEST_BUCKET_1}" --key "$1" | jq -r .ContentType)
|
||||||
|
Loading…
Reference in New Issue
Block a user