Преглед изворни кода

New ItemStart/Finished type 'metadata' for shortcut updates

Jakob Borg пре 10 година
родитељ
комит
d728320ece
1 измењених фајлова са 18 додато и 8 уклоњено
  1. 18 8
      internal/model/rwfolder.go

+ 18 - 8
internal/model/rwfolder.go

@@ -815,13 +815,6 @@ func (p *rwFolder) renameFile(source, target protocol.FileInfo) {
 // handleFile queues the copies and pulls as necessary for a single new or
 // handleFile queues the copies and pulls as necessary for a single new or
 // changed file.
 // changed file.
 func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocksState, finisherChan chan<- *sharedPullerState) {
 func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocksState, finisherChan chan<- *sharedPullerState) {
-	events.Default.Log(events.ItemStarted, map[string]interface{}{
-		"folder": p.folder,
-		"item":   file.Name,
-		"type":   "file",
-		"action": "update",
-	})
-
 	curFile, ok := p.model.CurrentFolderFile(p.folder, file.Name)
 	curFile, ok := p.model.CurrentFolderFile(p.folder, file.Name)
 
 
 	if ok && len(curFile.Blocks) == len(file.Blocks) && scanner.BlocksEqual(curFile.Blocks, file.Blocks) {
 	if ok && len(curFile.Blocks) == len(file.Blocks) && scanner.BlocksEqual(curFile.Blocks, file.Blocks) {
@@ -831,23 +824,40 @@ func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocks
 		if debug {
 		if debug {
 			l.Debugln(p, "taking shortcut on", file.Name)
 			l.Debugln(p, "taking shortcut on", file.Name)
 		}
 		}
+
+		events.Default.Log(events.ItemStarted, map[string]interface{}{
+			"folder": p.folder,
+			"item":   file.Name,
+			"type":   "file",
+			"action": "metadata",
+		})
+
 		p.queue.Done(file.Name)
 		p.queue.Done(file.Name)
+
 		var err error
 		var err error
 		if file.IsSymlink() {
 		if file.IsSymlink() {
 			err = p.shortcutSymlink(file)
 			err = p.shortcutSymlink(file)
 		} else {
 		} else {
 			err = p.shortcutFile(file)
 			err = p.shortcutFile(file)
 		}
 		}
+
 		events.Default.Log(events.ItemFinished, map[string]interface{}{
 		events.Default.Log(events.ItemFinished, map[string]interface{}{
 			"folder": p.folder,
 			"folder": p.folder,
 			"item":   file.Name,
 			"item":   file.Name,
 			"error":  events.Error(err),
 			"error":  events.Error(err),
 			"type":   "file",
 			"type":   "file",
-			"action": "update",
+			"action": "metadata",
 		})
 		})
 		return
 		return
 	}
 	}
 
 
+	events.Default.Log(events.ItemStarted, map[string]interface{}{
+		"folder": p.folder,
+		"item":   file.Name,
+		"type":   "file",
+		"action": "update",
+	})
+
 	scanner.PopulateOffsets(file.Blocks)
 	scanner.PopulateOffsets(file.Blocks)
 
 
 	// Figure out the absolute filenames we need once and for all
 	// Figure out the absolute filenames we need once and for all