Jelajahi Sumber

added function to delete file from remote:/${remotebasedir}

Jandalf81 7 tahun lalu
induk
melakukan
4efbf911be
1 mengubah file dengan 33 tambahan dan 0 penghapusan
  1. 33 0
      rclone_script.sh

+ 33 - 0
rclone_script.sh

@@ -287,6 +287,34 @@ function uploadSaves ()
 }
 
 
+function deleteFileFromRemote ()
+# deletes a file from the remote
+# INPUT
+#	$1 > relative filepath incl. name and extension to the local savepath
+# RETURN
+#	0 > file deteted successfully
+#	1 > connection not available
+#	2 > file could not be deleted
+{
+	fileToDelete="$1"
+	
+	getAvailableConnection
+	availableConnection=$?
+	if [[ ${availableConnection} -gt ${neededConnection} ]]
+	then 
+		log "ERROR" "Needed Connection not available. Needed ${neededConnection}, available ${availableConnection}"
+		return 1
+	fi
+	
+	rclone delete retropie:${remotebasedir}/${fileToDelete} 2>&1 >> ${logfile}
+	if [[ $? -eq 0 ]]
+	then
+		return 0
+	else
+		return 1
+	fi
+}
+
 ########
 # MAIN #
 ########
@@ -308,3 +336,8 @@ then
 	getTypeOfRemote
 	downloadSaves
 fi
+
+if [ "${direction}" == "delete" ]
+then
+	deleteFileFromRemote "${2}"
+fi