Repository: syncthing/syncthing
File: lib/model/folder_sendrecv.go (Go)

Code before:
			dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
			changed++

		case runtime.GOOS == "windows" && fs.WindowsInvalidFilename(file.Name):
			f.newPullError(file.Name, fs.ErrInvalidFilename)

		case file.IsDeleted():
			if file.IsDirectory() {
				// Perform directory deletions at the end, as we may have
				// files to delete inside them before we get to that point.
				dirDeletions = append(dirDeletions, file)
			} else if file.IsSymlink() {
				f.resetPullError(file.Name)
				f.deleteFile(file, dbUpdateChan, scanChan)
			} else {
				df, ok := f.fset.Get(protocol.LocalDeviceID, file.Name)
				// Local file can be already deleted, but with a lower version
				// number, hence the deletion coming in again as part of
				// WithNeed, furthermore, the file can simply be of the wrong
				// type if we haven't yet managed to pull it.
				if ok && !df.IsDeleted() && !df.IsSymlink() && !df.IsDirectory() && !df.IsInvalid() {
					fileDeletions[file.Name] = file
					// Put files into buckets per first hash
					key := string(df.Blocks[0].Hash)
					buckets[key] = append(buckets[key], df)
				} else {
					f.resetPullError(file.Name)
					f.deleteFileWithCurrent(file, df, ok, dbUpdateChan, scanChan)
				}
			}
			changed++

		case file.Type == protocol.FileInfoTypeFile:
			curFile, hasCurFile := f.fset.Get(protocol.LocalDeviceID, file.Name)
			if _, need := blockDiff(curFile.Blocks, file.Blocks); hasCurFile && len(need) == 0 {
				// We are supposed to copy the entire file, and then fetch nothing. We
				// are only updating metadata, so we don't actually *need* to make the
				// copy.
				f.resetPullError(file.Name)
				f.shortcutFile(file, curFile, dbUpdateChan)
			} else {
				// Queue files for processing after directories and symlinks.
				f.queue.Push(file.Name, file.Size, file.ModTime())
			}

		case runtime.GOOS == "windows" && file.IsSymlink():
			f.resetPullError(file.Name)
			file.SetUnsupported(f.shortID)
			l.Debugln(f, "Invalidating symlink (unsupported)", file.Name)
			dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
			changed++

Review comment (suggestion):
Almost feels like the delete should reset the error internally.

Code after:
			dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
			changed++

		case runtime.GOOS == "windows" && fs.WindowsInvalidFilename(file.Name):
			f.newPullError(file.Name, fs.ErrInvalidFilename)

		case file.IsDeleted():
			if file.IsDirectory() {
				// Perform directory deletions at the end, as we may have
				// files to delete inside them before we get to that point.
				dirDeletions = append(dirDeletions, file)
			} else if file.IsSymlink() {
				f.deleteFile(file, dbUpdateChan, scanChan)
			} else {
				df, ok := f.fset.Get(protocol.LocalDeviceID, file.Name)
				// Local file can be already deleted, but with a lower version
				// number, hence the deletion coming in again as part of
				// WithNeed, furthermore, the file can simply be of the wrong
				// type if we haven't yet managed to pull it.
				if ok && !df.IsDeleted() && !df.IsSymlink() && !df.IsDirectory() && !df.IsInvalid() {
					fileDeletions[file.Name] = file
					// Put files into buckets per first hash
					key := string(df.Blocks[0].Hash)
					buckets[key] = append(buckets[key], df)
				} else {
					f.deleteFileWithCurrent(file, df, ok, dbUpdateChan, scanChan)
				}
			}
			changed++

		case file.Type == protocol.FileInfoTypeFile:
			curFile, hasCurFile := f.fset.Get(protocol.LocalDeviceID, file.Name)
			if _, need := blockDiff(curFile.Blocks, file.Blocks); hasCurFile && len(need) == 0 {
				// We are supposed to copy the entire file, and then fetch nothing. We
				// are only updating metadata, so we don't actually *need* to make the
				// copy.
				f.shortcutFile(file, curFile, dbUpdateChan)
			} else {
				// Queue files for processing after directories and symlinks.
				f.queue.Push(file.Name, file.Size, file.ModTime())
			}

		case runtime.GOOS == "windows" && file.IsSymlink():
			f.resetPullError(file.Name)
			file.SetUnsupported(f.shortID)
			l.Debugln(f, "Invalidating symlink (unsupported)", file.Name)
			dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
			changed++

		case file.IsDirectory() && !file.IsSymlink():
			changed++