|
@@ -125,9 +125,13 @@ func moveLogFile(logfile string, target string, uuid string) {
|
|
|
|
|
|
func finishFileOperation(logfile string, uuid string) {
|
|
|
//Finishing the file operation.
|
|
|
+ //time.Sleep(20000 * time.Millisecond) //Added this line for debug purpose
|
|
|
writeLog(logfile, "[done] ", "Task finished successfully")
|
|
|
moveLogFile(logfile, "done", uuid)
|
|
|
fmt.Println("Done")
|
|
|
+ os.Chmod("log/", 0777) //Try to give log folder permissions to PHP for removal.
|
|
|
+ os.Chmod("log/done/", 0777)
|
|
|
+ os.Chmod("log/error/", 0777)
|
|
|
}
|
|
|
|
|
|
func initChk() {
|
|
@@ -221,12 +225,19 @@ func main() {
|
|
|
moveLogFile(logfile, "error", uuid)
|
|
|
panic("ERROR. Invalid source file or target directory.")
|
|
|
}
|
|
|
- err := os.Rename(from, target)
|
|
|
- if err != nil {
|
|
|
- writeLog(logfile, "[error] ", "Unable to move file due to unknown error.")
|
|
|
- moveLogFile(logfile, "error", uuid)
|
|
|
- panic("ERROR. Unable to move file due to unknown error.")
|
|
|
- }
|
|
|
+ /*
|
|
|
+ err := os.Rename(from, target)
|
|
|
+ if err != nil {
|
|
|
+ writeLog(logfile, "[error] ", "Unable to move file due to the following error: "+err.Error())
|
|
|
+ moveLogFile(logfile, "error", uuid)
|
|
|
+ panic("ERROR. Unable to move file due to unknown error.")
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //Replacing the rename with Copy + Delete to fix the golang issue of "Unable to move file to another drive"
|
|
|
+ Copy(from, target)
|
|
|
+ writeLog(logfile, "[info] ", "File Copy finished. Removing the original item")
|
|
|
+ os.Remove(from)
|
|
|
+ writeLog(logfile, "[info] ", "Original file removed. Removed filepath: "+from)
|
|
|
finishFileOperation(logfile, uuid)
|
|
|
} else if opr == "move_folder" {
|
|
|
//Move a folder
|
|
@@ -237,12 +248,18 @@ func main() {
|
|
|
moveLogFile(logfile, "error", uuid)
|
|
|
panic("ERROR. Invalid source file or target directory.")
|
|
|
}
|
|
|
- err := os.Rename(from, target)
|
|
|
- if err != nil {
|
|
|
- writeLog(logfile, "[error] ", "Unable to move folder due to unknown error.")
|
|
|
- moveLogFile(logfile, "error", uuid)
|
|
|
- panic("ERROR. Unable to move folder due to unknown error.")
|
|
|
- }
|
|
|
+ /*
|
|
|
+ err := os.Rename(from, target)
|
|
|
+ if err != nil {
|
|
|
+ writeLog(logfile, "[error] ", "Unable to move folder due to to the following error: "+err.Error())
|
|
|
+ moveLogFile(logfile, "error", uuid)
|
|
|
+ panic("ERROR. Unable to move folder due to unknown error.")
|
|
|
+ }
|
|
|
+ */
|
|
|
+ Copy(from, target)
|
|
|
+ writeLog(logfile, "[info] ", "File Copy finished. Removing the original item")
|
|
|
+ os.RemoveAll(from)
|
|
|
+ writeLog(logfile, "[info] ", "Original folder removed. Removed path: "+from)
|
|
|
finishFileOperation(logfile, uuid)
|
|
|
}
|
|
|
|