-
Notifications
You must be signed in to change notification settings - Fork 4
Dev-new-fixes-21 #104
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
Dev-new-fixes-21 #104
Changes from 2 commits
b2eed29
462b551
ac375f7
04e143a
1ce384d
2cb5ec0
10dce0b
f21b759
e2abd69
a4d5dc9
689370f
11ca46f
8e6967c
11c00ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1648,7 +1648,7 @@ processTheMoves() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_UNATTENDED_FOLDERS=$TOTALUNATTENDEDFOLDERS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Dry mode info: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ $TESTMODE = "yes" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$TESTMODE" = "yes" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "Warning: Test Mode: yes, running $MOVE_FILES_TOOL in dry-mode for moving $([ "$MOVE_FILES_TOOL" = "rsync" ] && echo 'and syncing')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1874,6 +1874,34 @@ processTheMoves() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Clean moved empty folders | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$ACTION" =~ "move" && "$FILETYPE" == "d" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DIR="${SOURCE}/${FILEPATH}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -d "$DIR" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvDebuglogger "Current folder: $DIR" "Clean Empty Moved Folder - Start Loop" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -e "${DIR}/.placeholder" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_count=".placeholder" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_count=$(find "$DIR" -type f | wc -l) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Count subdirectories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dir_count=$(find "$DIR" -mindepth 1 -type d | wc -l) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$file_count" -eq 0 ] && [ "$dir_count" -eq 0 ] && [ "$file_count" != ".placeholder" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$TESTMODE" = "no" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "Deleting moved empty folder: ${DIR}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rmdir "$DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "TEST MODE: Would delete moved empty folder: ${DIR}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "Not deleting folder: contains $file_count file(s), $dir_count subfolder(s): $DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Setting mover status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$ACTION" =~ "unattended" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_UNATTENDED_SIZE=$((REMAINING_UNATTENDED_SIZE - FILESIZE)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1885,29 +1913,41 @@ processTheMoves() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$ACTION" =~ "unattended to secondary" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_UNATTENDED_FILES files remaining from unattended to secondary ($(bytes_to_human "$REMAINING_UNATTENDED_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if there are any files or folders left | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$FILETYPE" = "f" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_UNATTENDED_FILES files remaining from unattended to secondary ($(bytes_to_human "$REMAINING_UNATTENDED_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_UNATTENDED_FOLDERS folders remaining from unattended to secondary" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif [[ "$ACTION" =~ "unattended to primary" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_UNATTENDED_FILES files remaining from unattended to primary ($(bytes_to_human "$REMAINING_UNATTENDED_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if there are any files or folders left | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$FILETYPE" = "f" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_UNATTENDED_FILES files remaining from unattended to primary ($(bytes_to_human "$REMAINING_UNATTENDED_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_UNATTENDED_FOLDERS folders remaining from unattended to primary" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1930
to
1944
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block of code contains duplicated logic for logging messages based on
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$SOURCE" =~ $PRIMARYSTORAGENAME ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_CACHE_SIZE=$((REMAINING_CACHE_SIZE - FILESIZE)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if there are any files or folders left | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$FILETYPE" = "f" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_CACHE_FILES=$((REMAINING_CACHE_FILES - NBLINKS)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_CACHE_FILES files remaining from caches to array ($(bytes_to_human "$REMAINING_CACHE_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_CACHE_FOLDERS=$((REMAINING_CACHE_FOLDERS - 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_CACHE_FOLDERS folders remaining from caches to array" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_CACHE_FILES files remaining from caches to array ($(bytes_to_human "$REMAINING_CACHE_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_ARRAY_SIZE=$((REMAINING_ARRAY_SIZE - FILESIZE)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if there are any files or folders left | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$FILETYPE" = "f" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_ARRAY_FILES=$((REMAINING_ARRAY_FILES - NBLINKS)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_ARRAY_FILES files remaining from array to caches ($(bytes_to_human "$REMAINING_ARRAY_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REMAINING_ARRAY_FOLDERS=$((REMAINING_ARRAY_FOLDERS - 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_ARRAY_FOLDERS folders remaining from array to caches" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mvlogger "$REMAINING_ARRAY_FILES files remaining from array to caches ($(bytes_to_human "$REMAINING_ARRAY_SIZE"))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1946
to
1966
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is significant code duplication in this local log_msg
if [[ "$SOURCE" =~ $PRIMARYSTORAGENAME ]]; then
REMAINING_CACHE_SIZE=$((REMAINING_CACHE_SIZE - FILESIZE))
# Check if there are any files or folders left
if [[ "$FILETYPE" = "f" ]]; then
REMAINING_CACHE_FILES=$((REMAINING_CACHE_FILES - NBLINKS))
log_msg="$REMAINING_CACHE_FILES files remaining from caches to array ($(bytes_to_human "$REMAINING_CACHE_SIZE"))"
else
REMAINING_CACHE_FOLDERS=$((REMAINING_CACHE_FOLDERS - 1))
log_msg="$REMAINING_CACHE_FOLDERS folders remaining from caches to array"
fi
else
REMAINING_ARRAY_SIZE=$((REMAINING_ARRAY_SIZE - FILESIZE))
# Check if there are any files or folders left
if [[ "$FILETYPE" = "f" ]]; then
REMAINING_ARRAY_FILES=$((REMAINING_ARRAY_FILES - NBLINKS))
log_msg="$REMAINING_ARRAY_FILES files remaining from array to caches ($(bytes_to_human "$REMAINING_ARRAY_SIZE"))"
else
REMAINING_ARRAY_FOLDERS=$((REMAINING_ARRAY_FOLDERS - 1))
log_msg="$REMAINING_ARRAY_FOLDERS folders remaining from array to caches"
fi
fi
mvlogger "$log_msg" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| moverStatusWrite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling
.placeholderfiles is buggy and will cause the script to fail. When a.placeholderfile is found,file_countis set to the string ".placeholder". The subsequent condition[ "$file_count" -eq 0 ]then attempts an arithmetic comparison on a string, which results in aninteger expression expectederror. The logic should be refactored to correctly handle the.placeholdercase separately to avoid this runtime error.