|  | @ -3,7 +3,6 @@ package Filesystem | 
														
													
														
															
																|  |  | import ( |  |  | import ( | 
														
													
														
															
																|  |  | "os" |  |  | "os" | 
														
													
														
															
																|  |  | "path/filepath" |  |  | "path/filepath" | 
														
													
														
															
																|  |  | "strings" |  |  |  | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | "github.com/vbauerster/mpb" |  |  | "github.com/vbauerster/mpb" | 
														
													
														
															
																|  |  | bolt "go.etcd.io/bbolt" |  |  | bolt "go.etcd.io/bbolt" | 
														
													
												
													
														
															
																|  | @ -13,7 +12,7 @@ import ( | 
														
													
														
															
																|  |  | "PackageManager/Variables" |  |  | "PackageManager/Variables" | 
														
													
														
															
																|  |  | ) |  |  | ) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | func pickFilesSingle(fileKey, filePath string) error { |  |  |  | 
														
													
														
															
																|  |  |  |  |  | func pickFilesSingle(filePath string) error { | 
														
													
														
															
																|  |  | var ( |  |  | var ( | 
														
													
														
															
																|  |  | indexBucket *bolt.Bucket |  |  | indexBucket *bolt.Bucket | 
														
													
														
															
																|  |  | picksBucket *bolt.Bucket |  |  | picksBucket *bolt.Bucket | 
														
													
												
													
														
															
																|  | @ -24,11 +23,11 @@ func pickFilesSingle(fileKey, filePath string) error { | 
														
													
														
															
																|  |  | indexBucket = tx.Bucket(Variables.FsHashIndexBucket) |  |  | indexBucket = tx.Bucket(Variables.FsHashIndexBucket) | 
														
													
														
															
																|  |  | picksBucket = tx.Bucket(Variables.FsHashPicksBucket) |  |  | picksBucket = tx.Bucket(Variables.FsHashPicksBucket) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | e = AddFileToBucket(picksBucket, fileKey, filePath) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | e = AddFileToBucket(picksBucket, filePath) | 
														
													
														
															
																|  |  | if e != nil { |  |  | if e != nil { | 
														
													
														
															
																|  |  | return e |  |  | return e | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | return RemoveFileFromBucket(indexBucket, fileKey) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | return RemoveFileFromBucket(indexBucket, filePath) | 
														
													
														
															
																|  |  | }) |  |  | }) | 
														
													
														
															
																|  |  | return e |  |  | return e | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
												
													
														
															
																|  | @ -40,7 +39,6 @@ func pickFilesRecursive(rootPath string) error { | 
														
													
														
															
																|  |  | picksBucket *bolt.Bucket |  |  | picksBucket *bolt.Bucket | 
														
													
														
															
																|  |  | bar         *mpb.Bar |  |  | bar         *mpb.Bar | 
														
													
														
															
																|  |  | totalLen    int |  |  | totalLen    int | 
														
													
														
															
																|  |  | trimF       string |  |  |  | 
														
													
														
															
																|  |  | f           string |  |  | f           string | 
														
													
														
															
																|  |  | e           error |  |  | e           error | 
														
													
														
															
																|  |  | ) |  |  | ) | 
														
													
												
													
														
															
																|  | @ -65,8 +63,7 @@ func pickFilesRecursive(rootPath string) error { | 
														
													
														
															
																|  |  | if len(fsStatus.NewFiles) > 0 { |  |  | if len(fsStatus.NewFiles) > 0 { | 
														
													
														
															
																|  |  | for _, f = range fsStatus.NewFiles { |  |  | for _, f = range fsStatus.NewFiles { | 
														
													
														
															
																|  |  | bar.Increment() |  |  | bar.Increment() | 
														
													
														
															
																|  |  | trimF = strings.TrimPrefix(f, Variables.RootDir) |  |  |  | 
														
													
														
															
																|  |  | e = AddFileToBucket(picksBucket, trimF, f) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | e = AddFileToBucket(picksBucket, f) | 
														
													
														
															
																|  |  | if e != nil { |  |  | if e != nil { | 
														
													
														
															
																|  |  | return e |  |  | return e | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
												
													
														
															
																|  | @ -76,8 +73,7 @@ func pickFilesRecursive(rootPath string) error { | 
														
													
														
															
																|  |  | if len(fsStatus.ModifiedFiles) > 0 { |  |  | if len(fsStatus.ModifiedFiles) > 0 { | 
														
													
														
															
																|  |  | for _, f = range fsStatus.ModifiedFiles { |  |  | for _, f = range fsStatus.ModifiedFiles { | 
														
													
														
															
																|  |  | bar.Increment() |  |  | bar.Increment() | 
														
													
														
															
																|  |  | trimF = strings.TrimPrefix(f, Variables.RootDir) |  |  |  | 
														
													
														
															
																|  |  | e = AddFileToBucket(picksBucket, trimF, f) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | e = AddFileToBucket(picksBucket, f) | 
														
													
														
															
																|  |  | if e != nil { |  |  | if e != nil { | 
														
													
														
															
																|  |  | return e |  |  | return e | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
												
													
														
															
																|  | @ -119,7 +115,7 @@ func PickFiles(rootPath string) error { | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | if !rootStat.IsDir() { |  |  | if !rootStat.IsDir() { | 
														
													
														
															
																|  |  | return pickFilesSingle(rootPath, realRootPath) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | return pickFilesSingle(realRootPath) | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | return pickFilesRecursive(realRootPath) |  |  | return pickFilesRecursive(realRootPath) | 
														
													
												
													
														
															
																|  | 
 |