Browse Source

Fixing upload refresh duplicate bug

TC pushbot 5 4 years ago
parent
commit
dda74c7306
54 changed files with 112 additions and 12 deletions
  1. BIN
      documents/1.120 release drawing/celebration card CMYK.jpg
  2. BIN
      documents/1.120 release drawing/celebration card CMYK.psd
  3. BIN
      documents/1.120 release drawing/celebration card.png
  4. BIN
      documents/1.120 release drawing/celebration card.psd
  5. BIN
      documents/Promotion Cards/Back.jpg
  6. BIN
      documents/Promotion Cards/Back.psd
  7. BIN
      documents/Promotion Cards/Front.jpg
  8. BIN
      documents/Promotion Cards/Front.psd
  9. BIN
      documents/Promotion Cards/icons/baseline_code_black_48dp.png
  10. BIN
      documents/Promotion Cards/icons/baseline_email_black_48dp.png
  11. BIN
      documents/Promotion Cards/icons/baseline_facebook_black_48dp.png
  12. BIN
      documents/Promotion Cards/icons/baseline_home_black_48dp.png
  13. BIN
      documents/Promotion Cards/link.png
  14. BIN
      documents/Promotion Cards/preview.png
  15. BIN
      documents/Promotion Cards/preview.psd
  16. 0 0
      legacy/Blog/backend/config.js
  17. 0 0
      legacy/Blog/backend/helper.js
  18. 0 0
      legacy/Blog/backend/hidePost.js
  19. 0 0
      legacy/Blog/backend/indexManager.js
  20. 0 0
      legacy/Blog/backend/jsondb.js
  21. 0 0
      legacy/Blog/backend/listPosts.js
  22. 0 0
      legacy/Blog/backend/loadFIle.js
  23. 0 0
      legacy/Blog/backend/publish.js
  24. 0 0
      legacy/Blog/backend/renderIndex.js
  25. 0 0
      legacy/Blog/backend/savePost.js
  26. 0 0
      legacy/Blog/editor.html
  27. 0 0
      legacy/Blog/framedEditor.html
  28. 0 0
      legacy/Blog/img/desktop_icon.png
  29. 0 0
      legacy/Blog/img/desktop_icon.psd
  30. 0 0
      legacy/Blog/img/module_icon.png
  31. 0 0
      legacy/Blog/img/module_icon.psd
  32. 0 0
      legacy/Blog/img/pwa/128.png
  33. 0 0
      legacy/Blog/img/pwa/192.png
  34. 0 0
      legacy/Blog/img/pwa/256.png
  35. 0 0
      legacy/Blog/img/pwa/512.png
  36. 0 0
      legacy/Blog/img/small_icon.png
  37. 0 0
      legacy/Blog/img/small_icon.psd
  38. 0 0
      legacy/Blog/index.html
  39. 0 0
      legacy/Blog/init.agi
  40. 0 0
      legacy/Blog/manifest.json
  41. 0 0
      legacy/Blog/script/suneditor/en.js
  42. 0 0
      legacy/Blog/script/suneditor/suneditor.min.css
  43. 0 0
      legacy/Blog/script/suneditor/suneditor.min.js
  44. 0 0
      legacy/Blog/setting.html
  45. 0 0
      legacy/Blog/template/blog.css
  46. 0 0
      legacy/Blog/template/footer.html
  47. 0 0
      legacy/Blog/template/index.html
  48. 0 0
      legacy/Blog/template/post.html
  49. 6 4
      mod/filesystem/filesystem.go
  50. 44 0
      mod/filesystem/hybridBackup/fastwalk.go
  51. 46 6
      mod/filesystem/hybridBackup/hybridBackup.go
  52. 4 0
      storage.go
  53. 5 0
      web/SystemAO/network/portforward.html
  54. 7 2
      web/desktop.system

BIN
documents/1.120 release drawing/celebration card CMYK.jpg


BIN
documents/1.120 release drawing/celebration card CMYK.psd


BIN
documents/1.120 release drawing/celebration card.png


BIN
documents/1.120 release drawing/celebration card.psd


BIN
documents/Promotion Cards/Back.jpg


BIN
documents/Promotion Cards/Back.psd


BIN
documents/Promotion Cards/Front.jpg


BIN
documents/Promotion Cards/Front.psd


BIN
documents/Promotion Cards/icons/baseline_code_black_48dp.png


BIN
documents/Promotion Cards/icons/baseline_email_black_48dp.png


BIN
documents/Promotion Cards/icons/baseline_facebook_black_48dp.png


BIN
documents/Promotion Cards/icons/baseline_home_black_48dp.png


BIN
documents/Promotion Cards/link.png


BIN
documents/Promotion Cards/preview.png


BIN
documents/Promotion Cards/preview.psd


+ 0 - 0
web/Blog/backend/config.js → legacy/Blog/backend/config.js


+ 0 - 0
web/Blog/backend/helper.js → legacy/Blog/backend/helper.js


+ 0 - 0
web/Blog/backend/hidePost.js → legacy/Blog/backend/hidePost.js


+ 0 - 0
web/Blog/backend/indexManager.js → legacy/Blog/backend/indexManager.js


+ 0 - 0
web/Blog/backend/jsondb.js → legacy/Blog/backend/jsondb.js


+ 0 - 0
web/Blog/backend/listPosts.js → legacy/Blog/backend/listPosts.js


+ 0 - 0
web/Blog/backend/loadFIle.js → legacy/Blog/backend/loadFIle.js


+ 0 - 0
web/Blog/backend/publish.js → legacy/Blog/backend/publish.js


+ 0 - 0
web/Blog/backend/renderIndex.js → legacy/Blog/backend/renderIndex.js


+ 0 - 0
web/Blog/backend/savePost.js → legacy/Blog/backend/savePost.js


+ 0 - 0
web/Blog/editor.html → legacy/Blog/editor.html


+ 0 - 0
web/Blog/framedEditor.html → legacy/Blog/framedEditor.html


+ 0 - 0
web/Blog/img/desktop_icon.png → legacy/Blog/img/desktop_icon.png


+ 0 - 0
web/Blog/img/desktop_icon.psd → legacy/Blog/img/desktop_icon.psd


+ 0 - 0
web/Blog/img/module_icon.png → legacy/Blog/img/module_icon.png


+ 0 - 0
web/Blog/img/module_icon.psd → legacy/Blog/img/module_icon.psd


+ 0 - 0
web/Blog/img/pwa/128.png → legacy/Blog/img/pwa/128.png


+ 0 - 0
web/Blog/img/pwa/192.png → legacy/Blog/img/pwa/192.png


+ 0 - 0
web/Blog/img/pwa/256.png → legacy/Blog/img/pwa/256.png


+ 0 - 0
web/Blog/img/pwa/512.png → legacy/Blog/img/pwa/512.png


+ 0 - 0
web/Blog/img/small_icon.png → legacy/Blog/img/small_icon.png


+ 0 - 0
web/Blog/img/small_icon.psd → legacy/Blog/img/small_icon.psd


+ 0 - 0
web/Blog/index.html → legacy/Blog/index.html


+ 0 - 0
web/Blog/init.agi → legacy/Blog/init.agi


+ 0 - 0
web/Blog/manifest.json → legacy/Blog/manifest.json


+ 0 - 0
web/Blog/script/suneditor/en.js → legacy/Blog/script/suneditor/en.js


+ 0 - 0
web/Blog/script/suneditor/suneditor.min.css → legacy/Blog/script/suneditor/suneditor.min.css


+ 0 - 0
web/Blog/script/suneditor/suneditor.min.js → legacy/Blog/script/suneditor/suneditor.min.js


+ 0 - 0
web/Blog/setting.html → legacy/Blog/setting.html


+ 0 - 0
web/Blog/template/blog.css → legacy/Blog/template/blog.css


+ 0 - 0
web/Blog/template/footer.html → legacy/Blog/template/footer.html


+ 0 - 0
web/Blog/template/index.html → legacy/Blog/template/index.html


+ 0 - 0
web/Blog/template/post.html → legacy/Blog/template/post.html


+ 6 - 4
mod/filesystem/filesystem.go

@@ -109,10 +109,12 @@ func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error) {
 		if option.Hierarchy == "backup" {
 			//Backup disk. Create an Hierarchy Config for this drive
 			hierarchySpecificConfig = hybridBackup.BackupConfig{
-				DiskUID:   option.Uuid,
-				DiskPath:  option.Path,
-				ParentUID: option.Parentuid,
-				Mode:      option.BackupMode,
+				CycleCounter:  0,
+				LastCycleTime: time.Now().Unix(),
+				DiskUID:       option.Uuid,
+				DiskPath:      option.Path,
+				ParentUID:     option.Parentuid,
+				Mode:          option.BackupMode,
 			}
 		}
 

+ 44 - 0
mod/filesystem/hybridBackup/fastwalk.go

@@ -0,0 +1,44 @@
+package hybridBackup
+
+import (
+	"io/ioutil"
+	"os"
+	"path/filepath"
+)
+
+/*
+	High speed file walk function with no file stats
+*/
+func fastWalk(root string, walkFunc func(string) error) error {
+	return walkDir(root, walkFunc)
+}
+
+func walkDir(dir string, walkFunc func(string) error) error {
+	files, err := ioutil.ReadDir(dir)
+	if err != nil {
+		return err
+	}
+
+	for _, f := range files {
+		if f.IsDir() {
+			err := walkDir(filepath.Join(dir, f.Name()), walkFunc)
+			if err != nil {
+				return err
+			}
+		} else if !f.IsDir() {
+			err := walkFunc(filepath.Join(dir, f.Name()))
+			if err != nil {
+				return err
+			}
+		}
+	}
+
+	return nil
+}
+
+func fileExists(filename string) bool {
+	if _, err := os.Stat(filename); os.IsNotExist(err) {
+		return false
+	}
+	return true
+}

+ 46 - 6
mod/filesystem/hybridBackup/hybridBackup.go

@@ -2,6 +2,9 @@ package hybridBackup
 
 import (
 	"log"
+	"path/filepath"
+	"strings"
+	"time"
 )
 
 /*
@@ -23,19 +26,55 @@ import (
 */
 
 type BackupConfig struct {
-	CycleCounter int64  //The number of backup executed in the background
-	DiskUID      string //The UID of the target fsandlr
-	DiskPath     string //The mount point for the disk
-	ParentUID    string //Parent virtal disk UUID
-	ParentPath   string //Parent disk path
-	Mode         string //Backup mode
+	CycleCounter  int64  //The number of backup executed in the background
+	LastCycleTime int64  //The execution time of the last cycle
+	DiskUID       string //The UID of the target fsandlr
+	DiskPath      string //The mount point for the disk
+	ParentUID     string //Parent virtal disk UUID
+	ParentPath    string //Parent disk path
+	Mode          string //Backup mode
 }
 
+//Main handler function for hybrid backup
 func HandleBackupProcess(backupConfig *BackupConfig) (string, error) {
 	log.Println(">>>>>> Running backup process: ", backupConfig)
+	rootPath := filepath.ToSlash(filepath.Clean(backupConfig.ParentPath))
+
+	//Check if the target disk is writable and mounted
+	if fileExists(filepath.Join(backupConfig.DiskPath, "aofs.db")) && fileExists(filepath.Join(backupConfig.DiskPath, "aofs.db.lock")) {
+		//This filesystem is mounted
+
+	} else {
+		//File system not mounted. Skipping
+		log.Println("*HybridBackup* Skipping backup cycle for " + backupConfig.ParentUID + ":/")
+		return "Parent drive (" + backupConfig.ParentUID + ":/) not mounted. Skipping", nil
+	}
 
 	if backupConfig.Mode == "smart" {
+		//Smart backup mode. Scan new files every minutes and compare creation time scan every hour minutes
+		if backupConfig.CycleCounter%5 == 0 {
+			//Perform deep backup, use walk function
+
+		} else {
+			//Perform shallow backup
+			fastWalk(rootPath, func(filename string) error {
+				rootAbs, _ := filepath.Abs(rootPath)
+				fileAbs, _ := filepath.Abs(filename)
+
+				rootAbs = filepath.ToSlash(filepath.Clean(rootAbs))
+				fileAbs = filepath.ToSlash(filepath.Clean(fileAbs))
+
+				relPath := strings.ReplaceAll(fileAbs, rootAbs, "")
+				assumedTargetPosition := filepath.Join(backupConfig.DiskPath, relPath)
+				if !fileExists(assumedTargetPosition) {
+					//Target file not exists in backup disk. Make a copy
+					//WIP
+					log.Println("Copying ", assumedTargetPosition)
+				}
 
+				return nil
+			})
+		}
 	} else if backupConfig.Mode == "nightly" {
 
 	} else if backupConfig.Mode == "append" {
@@ -44,6 +83,7 @@ func HandleBackupProcess(backupConfig *BackupConfig) (string, error) {
 
 	//Add one to the cycle counter
 	backupConfig.CycleCounter++
+	backupConfig.LastCycleTime = time.Now().Unix()
 
 	//Return the log information
 	return "", nil

+ 4 - 0
storage.go

@@ -125,6 +125,10 @@ func FilesystemDaemonInit() {
 
 			backupConfig.ParentPath = parentFileSystemHandler.Path
 
+			//Debug backup execution
+			backupConfig.CycleCounter = 1
+			hybridBackup.HandleBackupProcess(&backupConfig)
+
 			//Create a scheudler for this disk
 			systemScheduler.CreateNewScheduledFunctionJob("backup-daemon ["+thisHandler.UUID+"]",
 				"Backup daemon from "+backupConfig.ParentUID+":/ to "+backupConfig.DiskUID+":/",

+ 5 - 0
web/SystemAO/network/portforward.html

@@ -160,6 +160,11 @@
                 ports.push(parseInt(thisPort));
             });
 
+            if (ports.length == 0){
+                //Not selecting anything
+                return;
+            }
+
             //Confirm removal
             if (confirm("Confirm removing forward on: " + ports.join(", ") + "?")){
                 ports.forEach(port => {

+ 7 - 2
web/desktop.system

@@ -2709,6 +2709,11 @@
                     
                 }
 
+                //Update the desktop hash to prevent the auto refresh by hash
+                getDesktopHash(function(hash){
+                    desktopFileHash = hash;
+                });
+
                 if (callback !== undefined) {
                     //console.log(callback);
                     callback();
@@ -5196,8 +5201,8 @@
         function uploadFile(file, callback=undefined) {
             let url = 'system/file_system/upload'
             let uploadCurrentPath = "user:/Desktop/";
-            let formData = new FormData()
-            let xhr = new XMLHttpRequest()
+            let formData = new FormData();
+            let xhr = new XMLHttpRequest();
             formData.append('file', file);
             formData.append('path', uploadCurrentPath);