adding path checks to manager
This commit is contained in:
		@@ -36,12 +36,12 @@ func NewManager(version engine.Version, logLevel int, format string, informer ch
 | 
			
		||||
	log.SetLogLevel(logger.LogLevel(logLevel))
 | 
			
		||||
	var wg sync.WaitGroup
 | 
			
		||||
 | 
			
		||||
	watcher, err := engine.NewWatcher(log, KEYFOLDER, DOWNLOADFOLDER, SYNCFOLDER, THUMBFOLDER, DIFFFOLDER)
 | 
			
		||||
	watcher, err := engine.NewWatcher(log, KeyFolder, DownloadFolder, SyncFolder, ThumbFolder, DiffFolder)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.CriticalF("Error creating a watcher %s", err)
 | 
			
		||||
		return &Manager{}, err
 | 
			
		||||
	}
 | 
			
		||||
	patcher, err := engine.NewPatcher(log, KEYFOLDER, DOWNLOADFOLDER, SYNCFOLDER, THUMBFOLDER, DIFFFOLDER)
 | 
			
		||||
	patcher, err := engine.NewPatcher(log, KeyFolder, DownloadFolder, SyncFolder, ThumbFolder, DiffFolder)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.CriticalF("Error creating a patcher %s", err)
 | 
			
		||||
		return &Manager{}, err
 | 
			
		||||
@@ -161,7 +161,7 @@ func (m *Manager) AddFileToMonitor(file string, hardCopy bool) (string, error) {
 | 
			
		||||
		tmpFile.Path = file
 | 
			
		||||
		tmpFile.CreatedAt = time.Now()
 | 
			
		||||
		tmpFile.Unique = base64.URLEncoding.EncodeToString([]byte(filename)) + "_" + base64.URLEncoding.EncodeToString((tmpFile.CurrentHash[:])) + "_" + strconv.FormatInt(tmpFile.CreatedAt.Unix(), 10) + "_" + filename
 | 
			
		||||
		tmpFile.BkpLocation = filepath.Join(SYNCFOLDER, tmpFile.Unique)
 | 
			
		||||
		tmpFile.BkpLocation = filepath.Join(SyncFolder, tmpFile.Unique)
 | 
			
		||||
		tmpFile.CurrentBase = tmpFile.BkpLocation
 | 
			
		||||
		tmpFile.Ignore = false //we can have files in the database that are ignored. TODO: This was initially added so that 'All Files' would show up as a file (its a hack as it adds a dummy to the database)
 | 
			
		||||
		//we should now have a unique name for this file
 | 
			
		||||
@@ -260,7 +260,7 @@ func (m *Manager) BeginWatching() error {
 | 
			
		||||
 | 
			
		||||
						_, fileName := filepath.Split(diff.Object)
 | 
			
		||||
						unique := base64.URLEncoding.EncodeToString([]byte(fileName)) + "_" + base64.URLEncoding.EncodeToString((diff.ObjectHash[:])) + "_" + strconv.FormatInt(time.Now().Unix(), 10) + "_" + fileName
 | 
			
		||||
						restoreFile := filepath.Join(SYNCFOLDER, unique)
 | 
			
		||||
						restoreFile := filepath.Join(SyncFolder, unique)
 | 
			
		||||
						//generate a unique file name from the hash and the moment it was created
 | 
			
		||||
						//a sampled (and therefore) fast, hash of the file for 'uniqueness'
 | 
			
		||||
						if err := m.BeginForwardPatch(diff.Object, diff.DiffPath, restoreFile); err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user