Browse Source

Fixed Basic backup backing up cache file bug

Toby Chui 3 years ago
parent
commit
4602a617c7

+ 11 - 2
mod/disk/hybridBackup/basicBackup.go

@@ -7,6 +7,8 @@ import (
 	"path/filepath"
 	"strings"
 	"time"
+
+	"imuslab.com/arozos/mod/filesystem/hidden"
 )
 
 /*
@@ -53,6 +55,13 @@ func executeBackup(backupConfig *BackupTask, deepBackup bool) (string, error) {
 			//Reserved filename, skipping
 			return nil
 		}
+
+		isHiddenFile, _ := hidden.IsHidden(filename, true)
+		if isHiddenFile {
+			//Do not backup hidden files
+			return nil
+		}
+
 		//Get the target paste location
 		rootAbs, _ := filepath.Abs(rootPath)
 		fileAbs, _ := filepath.Abs(filename)
@@ -70,7 +79,7 @@ func executeBackup(backupConfig *BackupTask, deepBackup bool) (string, error) {
 				//Target file not exists in backup disk. Make a copy
 				if !fileExists(filepath.Dir(assumedTargetPosition)) {
 					//Folder containing this file not exists. Create it
-					os.MkdirAll(filepath.Dir(assumedTargetPosition), 0755)
+					os.MkdirAll(filepath.Dir(assumedTargetPosition), 0775)
 				}
 
 				//Copy the file to target
@@ -88,7 +97,7 @@ func executeBackup(backupConfig *BackupTask, deepBackup bool) (string, error) {
 			if !fileExists(assumedTargetPosition) {
 				if !fileExists(filepath.Dir(assumedTargetPosition)) {
 					//Folder containing this file not exists. Create it
-					os.MkdirAll(filepath.Dir(assumedTargetPosition), 0755)
+					os.MkdirAll(filepath.Dir(assumedTargetPosition), 0775)
 				}
 
 				//Copy the file to target

+ 2 - 2
mod/disk/hybridBackup/hybridBackup.go

@@ -222,12 +222,12 @@ func (m *Manager) Close() error {
 //Main handler function for hybrid backup
 func (backupConfig *BackupTask) HandleBackupProcess() (string, error) {
 	//Check if the target disk is writable and mounted
-	if fileExists(filepath.Join(backupConfig.ParentPath, "aofs.db")) && fileExists(filepath.Join(backupConfig.ParentPath, "aofs.db.lock")) {
+	if fileExists(filepath.Join(backupConfig.ParentPath, "aofs.db")) {
 		//This parent filesystem is mounted
 
 	} else {
 		//Parent File system not mounted.Terminate backup scheduler
-		log.Println("[HybridBackup] Skipping backup cycle for " + backupConfig.ParentUID + ":/")
+		log.Println("[HybridBackup] Skipping backup cycle for " + backupConfig.ParentUID + ":/, Parent drive not mounted")
 		return "Parent drive (" + backupConfig.ParentUID + ":/) not mounted", nil
 	}
 

+ 7 - 0
mod/disk/hybridBackup/versionBackup.go

@@ -9,6 +9,7 @@ import (
 	"time"
 
 	"imuslab.com/arozos/mod/disk/diskcapacity/dftool"
+	"imuslab.com/arozos/mod/filesystem/hidden"
 )
 
 /*
@@ -92,6 +93,12 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
 			return nil
 		}
 
+		isHiddenFile, _ := hidden.IsHidden(filename, true)
+		if isHiddenFile {
+			//Do not backup hidden files
+			return nil
+		}
+
 		//Get the target paste location
 		fileAbs, _ := filepath.Abs(filename)
 		fileAbs = filepath.ToSlash(filepath.Clean(fileAbs))