Various style fixes

This commit is contained in:
Jakob Borg
2014-12-08 16:36:15 +01:00
parent 12d69e25dd
commit 9d07aa006d
13 changed files with 78 additions and 82 deletions

View File

@@ -92,13 +92,13 @@ func (f *FolderConfiguration) HasMarker() bool {
return true
}
func (r *FolderConfiguration) DeviceIDs() []protocol.DeviceID {
if r.deviceIDs == nil {
for _, n := range r.Devices {
r.deviceIDs = append(r.deviceIDs, n.DeviceID)
func (f *FolderConfiguration) DeviceIDs() []protocol.DeviceID {
if f.deviceIDs == nil {
for _, n := range f.Devices {
f.deviceIDs = append(f.deviceIDs, n.DeviceID)
}
}
return r.deviceIDs
return f.deviceIDs
}
type VersioningConfiguration struct {

View File

@@ -86,7 +86,7 @@ const BufferSize = 64
type Logger struct {
subs map[int]*Subscription
nextId int
nextID int
mutex sync.Mutex
}
@@ -120,15 +120,15 @@ func NewLogger() *Logger {
func (l *Logger) Log(t EventType, data interface{}) {
l.mutex.Lock()
if debug {
dl.Debugln("log", l.nextId, t.String(), data)
dl.Debugln("log", l.nextID, t.String(), data)
}
e := Event{
ID: l.nextId,
ID: l.nextID,
Time: time.Now(),
Type: t,
Data: data,
}
l.nextId++
l.nextID++
for _, s := range l.subs {
if s.mask&t != 0 {
select {
@@ -148,10 +148,10 @@ func (l *Logger) Subscribe(mask EventType) *Subscription {
}
s := &Subscription{
mask: mask,
id: l.nextId,
id: l.nextID,
events: make(chan Event, BufferSize),
}
l.nextId++
l.nextID++
l.subs[s.id] = s
l.mutex.Unlock()
return s

View File

@@ -169,9 +169,8 @@ func parseIgnoreFile(fd io.Reader, currentFile string, seen map[string]bool) (*M
includes, err := loadIgnoreFile(includeFile, seen)
if err != nil {
return err
} else {
exps.patterns = append(exps.patterns, includes.patterns...)
}
exps.patterns = append(exps.patterns, includes.patterns...)
} else {
// Path name or pattern, add it so it matches files both in
// current directory and subdirs.

View File

@@ -37,7 +37,7 @@ func newDeviceActivity() *deviceActivity {
func (m *deviceActivity) leastBusy(availability []protocol.DeviceID) protocol.DeviceID {
m.mut.Lock()
var low int = 2<<30 - 1
low := 2<<30 - 1
var selected protocol.DeviceID
for _, device := range availability {
if usage := m.act[device]; usage < low {

View File

@@ -862,11 +862,11 @@ func (m *Model) deviceStatRef(deviceID protocol.DeviceID) *stats.DeviceStatistic
if sr, ok := m.deviceStatRefs[deviceID]; ok {
return sr
} else {
sr = stats.NewDeviceStatisticsReference(m.db, deviceID)
m.deviceStatRefs[deviceID] = sr
return sr
}
sr := stats.NewDeviceStatisticsReference(m.db, deviceID)
m.deviceStatRefs[deviceID] = sr
return sr
}
func (m *Model) deviceWasSeen(deviceID protocol.DeviceID) {

View File

@@ -201,7 +201,7 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
}
}
var flags uint32 = protocol.FlagDirectory
flags := uint32(protocol.FlagDirectory)
if w.IgnorePerms {
flags |= protocol.FlagNoPermBits | 0777
} else {

View File

@@ -190,16 +190,16 @@ func TestVerify(t *testing.T) {
type fileList []protocol.FileInfo
func (f fileList) Len() int {
return len(f)
func (l fileList) Len() int {
return len(l)
}
func (f fileList) Less(a, b int) bool {
return f[a].Name < f[b].Name
func (l fileList) Less(a, b int) bool {
return l[a].Name < l[b].Name
}
func (f fileList) Swap(a, b int) {
f[a], f[b] = f[b], f[a]
func (l fileList) Swap(a, b int) {
l[a], l[b] = l[b], l[a]
}
func (l fileList) testfiles() testfileList {

View File

@@ -48,7 +48,7 @@ func init() {
}
// A wrapper around actual implementations
func UpgradeTo(rel Release) error {
func To(rel Release) error {
select {
case <-upgradeUnlocked:
path, err := osext.Executable()

View File

@@ -86,15 +86,15 @@ func LatestRelease(prerelease bool) (Release, error) {
if prerelease {
// We are a beta version. Use the latest.
return rels[0], nil
} else {
// We are a regular release. Only consider non-prerelease versions for upgrade.
for _, rel := range rels {
if !rel.Prerelease {
return rel, nil
}
}
return Release{}, ErrVersionUnknown
}
// We are a regular release. Only consider non-prerelease versions for upgrade.
for _, rel := range rels {
if !rel.Prerelease {
return rel, nil
}
}
return Release{}, ErrVersionUnknown
}
func readTarGZ(url string, dir string) (string, error) {

View File

@@ -62,9 +62,8 @@ func (v Simple) Archive(filePath string) error {
l.Debugln("not archiving nonexistent file", filePath)
}
return nil
} else {
return err
}
return err
}
versionsDir := filepath.Join(v.folderPath, ".stversions")

View File

@@ -294,9 +294,8 @@ func (v Staggered) Archive(filePath string) error {
l.Debugln("not archiving nonexistent file", filePath)
}
return nil
} else {
return err
}
return err
}
if _, err := os.Stat(v.versionsPath); err != nil {