From dc6430d887d92fbebf48e14c500bb81423f3b950 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Mon, 7 Feb 2022 17:42:05 +0100 Subject: [PATCH] Hash the storage with md5 if length > 64 Signed-off-by: Louis Chemineau --- list_problematic_files_on_fs.sh | 16 +++++++++++++--- solvable_files.sh | 20 ++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/list_problematic_files_on_fs.sh b/list_problematic_files_on_fs.sh index 6786508..69c4756 100755 --- a/list_problematic_files_on_fs.sh +++ b/list_problematic_files_on_fs.sh @@ -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 diff --git a/solvable_files.sh b/solvable_files.sh index 89168fa..7a5ab6e 100755 --- a/solvable_files.sh +++ b/solvable_files.sh @@ -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=$( @@ -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" ] @@ -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=$( @@ -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" ] @@ -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