Bladeren bron

Better file paths

Zachary Kotlarek 11 jaren geleden
bovenliggende
commit
eea022eadb
2 gewijzigde bestanden met toevoegingen van 11 en 7 verwijderingen
  1. 1 1
      sync/sync.sh
  2. 10 6
      sync/syncUnwatched.sh

+ 1 - 1
sync/sync.sh

@@ -92,7 +92,7 @@ for infile in $FILES; do
 	# Skip files that exist
 	# Skip files that exist
 	if ls "${OUT_DIR}/${nobase}".* >/dev/null 2>&1; then
 	if ls "${OUT_DIR}/${nobase}".* >/dev/null 2>&1; then
 		if [ $DEBUG -gt 0 ]; then
 		if [ $DEBUG -gt 0 ]; then
-			echo "Skipping: ${infile}" 1>&2
+			echo "Exists: ${SUB_DIR}/${infile}" 1>&2
 		fi
 		fi
 		continue
 		continue
 	fi
 	fi

+ 10 - 6
sync/syncUnwatched.sh

@@ -85,15 +85,17 @@ done
 # Encode and allow any expected files
 # Encode and allow any expected files
 IFS=$'\n'
 IFS=$'\n'
 for i in $FILES; do
 for i in $FILES; do
+	FILE="${MEDIA_PATH}/${i}"
+
 	# Give up if the media path goes away
 	# Give up if the media path goes away
 	if ! ~/bin/video/isMediaMounted; then
 	if ! ~/bin/video/isMediaMounted; then
 		exit
 		exit
 	fi
 	fi
 
 
 	# Skip if the input file does not exist
 	# Skip if the input file does not exist
-	if [ ! -r "${i}" ]; then
+	if [ ! -r "${FILE}" ]; then
 		if [ $DEBUG -gt 0 ]; then
 		if [ $DEBUG -gt 0 ]; then
-			echo "Missing input path: ${i}" 1>&2
+			echo "Missing input path: ${FILE}" 1>&2
 		fi
 		fi
 		continue
 		continue
 	fi
 	fi
@@ -115,8 +117,10 @@ done
 IFS=$'\n'
 IFS=$'\n'
 MIN_AGE="`date -v -1H +%s`"
 MIN_AGE="`date -v -1H +%s`"
 for i in $OLD_FILES; do
 for i in $OLD_FILES; do
+	FILE="${BASE_DIR}/${i}"
+
 	# Skip if the input file does not exist
 	# Skip if the input file does not exist
-	if [ ! -r "${i}" ]; then
+	if [ ! -r "${FILE}" ]; then
 		if [ $DEBUG -gt 0 ]; then
 		if [ $DEBUG -gt 0 ]; then
 			echo "Missing delete path: ${i}" 1>&2
 			echo "Missing delete path: ${i}" 1>&2
 		fi
 		fi
@@ -124,13 +128,13 @@ for i in $OLD_FILES; do
 	fi
 	fi
 
 
 	# Skip files under 1H old to avoid churn and provide a no-delete signal for other conditions (e.g. filename encoding)
 	# Skip files under 1H old to avoid churn and provide a no-delete signal for other conditions (e.g. filename encoding)
-	STAT="`stat -f '%m' "${BASE_DIR}/${i}" 2>/dev/null`"
+	STAT="`stat -f '%m' "${FILE}" 2>/dev/null`"
 	if [ -z "${STAT}" ]; then
 	if [ -z "${STAT}" ]; then
 		STAT=1
 		STAT=1
 	fi
 	fi
 	if [ $STAT -ge $MIN_AGE ]; then
 	if [ $STAT -ge $MIN_AGE ]; then
 		if [ $DEBUG -gt 0 ]; then
 		if [ $DEBUG -gt 0 ]; then
-			echo "Will skip due to minimum age: ${BASE_DIR}/${i}" 1>&2
+			echo "Will skip due to minimum age: ${FILE}" 1>&2
 		fi
 		fi
 		continue
 		continue
 	fi
 	fi
@@ -140,7 +144,7 @@ for i in $OLD_FILES; do
 		echo "Will delete: ${BASE_DIR}/${i}" 1>&2
 		echo "Will delete: ${BASE_DIR}/${i}" 1>&2
 	fi
 	fi
 	if [ $NO_SYNC -eq 0 ]; then
 	if [ $NO_SYNC -eq 0 ]; then
-		rm -f "${BASE_DIR}/${i}"
+		rm -f "${FILE}"
 	fi
 	fi
 done
 done
 find "${DEST_DIR}" -type d -empty -delete
 find "${DEST_DIR}" -type d -empty -delete