Dont warn about irrelevant symlinks, print path to culprit (ref #1945)

This skips the warning about "unsupported symlinks" for invalid or
deleted symlinks (and as a side effect also accepts them into the index,
which should be fine). It also prints the affected file paths to the
log. This should be in the hypothetical list of "errored files" we
should present instead of the cryptic "puller stopped" message in the
future...
This commit is contained in:
Jakob Borg 2015-06-15 00:44:24 +02:00
parent fee0d7168a
commit 070a308217

View File

@ -99,7 +99,7 @@ type Model struct {
}
var (
SymlinkWarning = stdsync.Once{}
symlinkWarning = stdsync.Once{}
)
// NewModel creates and starts a new model. The model starts in read-only mode,
@ -512,7 +512,7 @@ func (m *Model) Index(deviceID protocol.DeviceID, folder string, fs []protocol.F
}
fs[i] = fs[len(fs)-1]
fs = fs[:len(fs)-1]
} else if symlinkInvalid(fs[i].IsSymlink()) {
} else if symlinkInvalid(folder, fs[i]) {
if debug {
l.Debugln("dropping update for unsupported symlink", fs[i])
}
@ -566,7 +566,7 @@ func (m *Model) IndexUpdate(deviceID protocol.DeviceID, folder string, fs []prot
}
fs[i] = fs[len(fs)-1]
fs = fs[:len(fs)-1]
} else if symlinkInvalid(fs[i].IsSymlink()) {
} else if symlinkInvalid(folder, fs[i]) {
if debug {
l.Debugln("dropping update for unsupported symlink", fs[i])
}
@ -1072,7 +1072,7 @@ func sendIndexTo(initial bool, minLocalVer int64, conn protocol.Connection, fold
maxLocalVer = f.LocalVersion
}
if ignores.Match(f.Name) || symlinkInvalid(f.IsSymlink()) {
if ignores.Match(f.Name) || symlinkInvalid(folder, f) {
if debug {
l.Debugln("not sending update for ignored/unsupported symlink", f)
}
@ -1360,7 +1360,7 @@ nextSub:
batch = batch[:0]
}
if ignores.Match(f.Name) || symlinkInvalid(f.IsSymlink()) {
if ignores.Match(f.Name) || symlinkInvalid(folder, f) {
// File has been ignored or an unsupported symlink. Set invalid bit.
if debug {
l.Debugln("setting invalid bit on ignored", f)
@ -1774,11 +1774,21 @@ func (m *Model) CommitConfiguration(from, to config.Configuration) bool {
return true
}
func symlinkInvalid(isLink bool) bool {
if !symlinks.Supported && isLink {
SymlinkWarning.Do(func() {
func symlinkInvalid(folder string, fi db.FileIntf) bool {
if !symlinks.Supported && fi.IsSymlink() && !fi.IsInvalid() && !fi.IsDeleted() {
symlinkWarning.Do(func() {
l.Warnln("Symlinks are disabled, unsupported or require Administrator privileges. This might cause your folder to appear out of sync.")
})
// Need to type switch for the concrete type to be able to access fields...
var name string
switch fi := fi.(type) {
case protocol.FileInfo:
name = fi.Name
case db.FileInfoTruncated:
name = fi.Name
}
l.Infoln("Unsupported symlink", name, "in folder", folder)
return true
}
return false