This commit is contained in:
adam committed 2024-10-21 17:01:59 +01:00
1 parent e9175bc139
commit e5f034b394
1 file changed
+17 -13
+17 -13
View File
@@ -26,7 +26,7 @@ function import_files {
if [[ "$file" =~ ^eidf[a-zA-Z0-9]{2,5}-[a-zA-Z0-9]{3,8}-.+$ ]] && [[ -f "$filepath" ]]; then
echo "File '$file' is formatted correctly"
else
echo "IMPORT FAILED FOR '$file'. Incorrect formatting." | tee -a $TODAY_FAILURES
echo "IMPORT FAILED FOR '$file'. Incorrect formatting." | tee -a $TODAY_FAILURES
continue
fi
@@ -59,9 +59,10 @@ function import_files {
;;
esac
# Extra Check - If file has been modified in the last 3 minutes, don't move it
if (( $(date +%s) - $(stat -c %Y "$LANDING_DIR/$file") < (6*3) )); then
echo "File $file modified in the last 3 minutes. Waiting for upload to complete"
continue
echo "File $file modified in the last 3 minutes. Waiting for upload to complete"
continue
fi
echo $project 'directory mounted at' $project_mount
@@ -70,6 +71,9 @@ function import_files {
read -r sha256 _ < <(/usr/bin/sha256sum "$filepath")
printf '%s | %s\n' "$sha256" "$filepath" | tee -a $TODAY_INGRESS
# Extracts Windows/Linux from $project_mount and sets the 'environment' vairable
# This changes the moving path depending if window or Linux
local environment="${project_mount#/mnt/}"
local environment="${environment%%/*}"
@@ -78,11 +82,11 @@ function import_files {
echo "IMPORT FAILED FOR FILE $file - Study could not be identified"
continue
else
echo "$LANDING_DIR/$file $project_mount/Import/$study"
mv $LANDING_DIR/$file $project_mount/Import/$study
echo "$LANDING_DIR/$file $project_mount/Import/$study"
mv $LANDING_DIR/$file $project_mount/Import/$study
fi
elif [[ $environment == "linux" ]]; then
echo "$filepath $project_mount/Import"
echo "$filepath $project_mount/Import"
mv "$filepath" $project_mount/Import
chown root:$project "$project_mount/Import/$file"
else
@@ -103,9 +107,9 @@ function export_files {
local project="${project%%/Export/*}"
if (( $(date +%s) - $(stat -c %Y $filepath) < (60*3) )); then
echo "File $file has been modified in the last 3 minutes. Waiting for write to complete"
continue
fi
echo "File $file has been modified in the last 3 minutes. Waiting for write to complete"
continue
fi
echo "$file from $project will be exported"
@@ -117,7 +121,7 @@ function export_files {
echo $new_filename
read -r sha256 _ < <(/usr/bin/sha256sum "$filepath")
printf '%s | %s\n' "$sha256" "$new_filename" | tee -a $TODAY_EGRESS
printf '%s | %s\n' "$sha256" "$new_filename" | tee -a $TODAY_EGRESS
mv "$filepath" "$EXPORT_DIR/$new_filename"
chgrp $project "$EXPORT_DIR/$new_filename"
@@ -144,8 +148,8 @@ function export_files {
if (( $(date +%s) - $(stat -c %Y $filepath) < (60*3) )); then
echo "File $file has been modified in the last 3 minutes. Waiting for write to complete"
continue
fi
continue
fi
echo "$file from $project will be exported"
@@ -157,7 +161,7 @@ function export_files {
echo "$file will be renamed $new_filename"
read -r sha256 _ < <(/usr/bin/sha256sum "$filepath")
printf '%s | %s\n' "$sha256" "$new_filename" | tee -a $TODAY_EGRESS
printf '%s | %s\n' "$sha256" "$new_filename" | tee -a $TODAY_EGRESS
if [[ "$file" == mft-* ]]; then
mv "$filepath" "/mnt/os-transfer/windows-mft/$project/$study/Export/$new_filename"