Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash the storage with md5 if length > 64 #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions list_problematic_files_on_fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@ function check_file() {

if [ "$username" == "__groupfolders" ]
then
# Two // to match the DB output.
echo "local::$data_dir//$relative_filepath"
# Ending with '/' to match the DB output.
storage="local::$data_dir/"
problematic_file="$relative_filepath"
else
echo "home::$relative_filepath"
storage="home::$username"
problematic_file="${relative_filepath/#$username\//}"
fi

if [ "${#storage}" -le "64" ]
then
echo "$storage/$problematic_file"
else
storage_md5=$(printf '%s' "$storage" | md5sum | awk '{print $1}')
echo "$storage_md5/$problematic_file"
fi
}
export -f check_file
Expand Down
20 changes: 16 additions & 4 deletions solvable_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ function correct_mtime() {

if [ "$username" == "__groupfolders" ]
then
storage="local::$data_dir/"
if [ "${#storage}" -gt "64" ]
then
storage=$(printf '%s' "$storage" | md5sum | awk '{print $1}')
fi

if [ "$db_type" == "mysql" ]
then
mtime_in_db=$(
Expand All @@ -49,7 +55,7 @@ function correct_mtime() {
--execute="\
SELECT mtime
FROM oc_storages JOIN oc_filecache ON oc_storages.numeric_id = oc_filecache.storage \
WHERE oc_storages.id='local::$data_dir/' AND oc_filecache.path=FROM_BASE64('$base64_relative_filepath')" \
WHERE oc_storages.id='$storage' AND oc_filecache.path=FROM_BASE64('$base64_relative_filepath')" \
"$db_name"
)
elif [ "$db_type" == "pgsql" ]
Expand All @@ -62,10 +68,16 @@ function correct_mtime() {
--command="\
SELECT mtime
FROM oc_storages JOIN oc_filecache ON oc_storages.numeric_id = oc_filecache.storage \
WHERE oc_storages.id='local::$data_dir/' AND oc_filecache.path=CONVERT_FROM(DECODE('$base64_relative_filepath', 'base64'), 'UTF-8')"
WHERE oc_storages.id='$storage' AND oc_filecache.path=CONVERT_FROM(DECODE('$base64_relative_filepath', 'base64'), 'UTF-8')"
)
fi
else
storage="home::$username"
if [ "${#storage}" -gt "64" ]
then
storage=$(printf '%s' "$storage" | md5sum | awk '{print $1}')
fi

if [ "$db_type" == "mysql" ]
then
mtime_in_db=$(
Expand All @@ -79,7 +91,7 @@ function correct_mtime() {
--execute="\
SELECT mtime
FROM oc_storages JOIN oc_filecache ON oc_storages.numeric_id = oc_filecache.storage \
WHERE oc_storages.id='home::$username' AND oc_filecache.path=FROM_BASE64('$base64_relative_filepath_without_username')" \
WHERE oc_storages.id='$storage' AND oc_filecache.path=FROM_BASE64('$base64_relative_filepath_without_username')" \
"$db_name"
)
elif [ "$db_type" == "pgsql" ]
Expand All @@ -92,7 +104,7 @@ function correct_mtime() {
--command="\
SELECT mtime
FROM oc_storages JOIN oc_filecache ON oc_storages.numeric_id = oc_filecache.storage \
WHERE oc_storages.id='home::$username' AND oc_filecache.path=CONVERT_FROM(DECODE('$base64_relative_filepath_without_username', 'base64'), 'UTF-8')"
WHERE oc_storages.id='$storage' AND oc_filecache.path=CONVERT_FROM(DECODE('$base64_relative_filepath_without_username', 'base64'), 'UTF-8')"
)
fi
fi
Expand Down