mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-11 02:36:17 +00:00
Merge pull request #1947 from calmh/metadata
Differentiate between content and metadata updates in ItemStarted/ItemFinished
This commit is contained in:
commit
1e35383b4d
@ -528,7 +528,7 @@ nextFile:
|
|||||||
// handleDir creates or updates the given directory
|
// handleDir creates or updates the given directory
|
||||||
func (p *rwFolder) handleDir(file protocol.FileInfo) {
|
func (p *rwFolder) handleDir(file protocol.FileInfo) {
|
||||||
var err error
|
var err error
|
||||||
events.Default.Log(events.ItemStarted, map[string]interface{}{
|
events.Default.Log(events.ItemStarted, map[string]string{
|
||||||
"folder": p.folder,
|
"folder": p.folder,
|
||||||
"item": file.Name,
|
"item": file.Name,
|
||||||
"type": "dir",
|
"type": "dir",
|
||||||
@ -611,7 +611,7 @@ func (p *rwFolder) handleDir(file protocol.FileInfo) {
|
|||||||
// deleteDir attempts to delete the given directory
|
// deleteDir attempts to delete the given directory
|
||||||
func (p *rwFolder) deleteDir(file protocol.FileInfo) {
|
func (p *rwFolder) deleteDir(file protocol.FileInfo) {
|
||||||
var err error
|
var err error
|
||||||
events.Default.Log(events.ItemStarted, map[string]interface{}{
|
events.Default.Log(events.ItemStarted, map[string]string{
|
||||||
"folder": p.folder,
|
"folder": p.folder,
|
||||||
"item": file.Name,
|
"item": file.Name,
|
||||||
"type": "dir",
|
"type": "dir",
|
||||||
@ -657,7 +657,7 @@ func (p *rwFolder) deleteDir(file protocol.FileInfo) {
|
|||||||
// deleteFile attempts to delete the given file
|
// deleteFile attempts to delete the given file
|
||||||
func (p *rwFolder) deleteFile(file protocol.FileInfo) {
|
func (p *rwFolder) deleteFile(file protocol.FileInfo) {
|
||||||
var err error
|
var err error
|
||||||
events.Default.Log(events.ItemStarted, map[string]interface{}{
|
events.Default.Log(events.ItemStarted, map[string]string{
|
||||||
"folder": p.folder,
|
"folder": p.folder,
|
||||||
"item": file.Name,
|
"item": file.Name,
|
||||||
"type": "file",
|
"type": "file",
|
||||||
@ -706,13 +706,13 @@ func (p *rwFolder) deleteFile(file protocol.FileInfo) {
|
|||||||
// and set the right attributes on it.
|
// and set the right attributes on it.
|
||||||
func (p *rwFolder) renameFile(source, target protocol.FileInfo) {
|
func (p *rwFolder) renameFile(source, target protocol.FileInfo) {
|
||||||
var err error
|
var err error
|
||||||
events.Default.Log(events.ItemStarted, map[string]interface{}{
|
events.Default.Log(events.ItemStarted, map[string]string{
|
||||||
"folder": p.folder,
|
"folder": p.folder,
|
||||||
"item": source.Name,
|
"item": source.Name,
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"action": "delete",
|
"action": "delete",
|
||||||
})
|
})
|
||||||
events.Default.Log(events.ItemStarted, map[string]interface{}{
|
events.Default.Log(events.ItemStarted, map[string]string{
|
||||||
"folder": p.folder,
|
"folder": p.folder,
|
||||||
"item": target.Name,
|
"item": target.Name,
|
||||||
"type": "file",
|
"type": "file",
|
||||||
@ -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]string{
|
||||||
|
"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]string{
|
||||||
|
"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
|
||||||
|
Loading…
Reference in New Issue
Block a user