From d2205228fb1676d4f6a176c936a888758a4f2380 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Mon, 25 May 2015 12:43:19 +0200 Subject: [PATCH 1/9] Make syncthing honor both the ignorePerms and FlagNoPermBits settings (fixes #1871) --- internal/model/rwfolder.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/model/rwfolder.go b/internal/model/rwfolder.go index 9c2c0f24e..02d55952b 100644 --- a/internal/model/rwfolder.go +++ b/internal/model/rwfolder.go @@ -109,6 +109,13 @@ func newRWFolder(m *Model, shortID uint64, cfg config.FolderConfiguration) *rwFo } } +// Helper function to check whether either the ignorePerm flag has been +// set on the local host or the FlagNoPermBits has been set on the file/dir +// which is being pulled. +func (p *rwFolder) ignorePermissions(file protocol.FileInfo) bool { + return p.ignorePerms || file.Flags&protocol.FlagNoPermBits != 0 +} + // Serve will run scans and pulls. It will return when Stop()ed or on a // critical error. func (p *rwFolder) Serve() { @@ -540,7 +547,7 @@ func (p *rwFolder) handleDir(file protocol.FileInfo) { realName := filepath.Join(p.dir, file.Name) mode := os.FileMode(file.Flags & 0777) - if p.ignorePerms { + if p.ignorePermissions(file) { mode = 0777 } @@ -569,7 +576,7 @@ func (p *rwFolder) handleDir(file protocol.FileInfo) { // not MkdirAll because the parent should already exist. mkdir := func(path string) error { err = os.Mkdir(path, mode) - if err != nil || p.ignorePerms { + if err != nil || p.ignorePermissions(file) { return err } return os.Chmod(path, mode) @@ -592,7 +599,7 @@ func (p *rwFolder) handleDir(file protocol.FileInfo) { // don't handle modification times on directories, because that sucks...) // It's OK to change mode bits on stuff within non-writable directories. - if p.ignorePerms { + if p.ignorePermissions(file) { p.dbUpdates <- file } else if err := os.Chmod(realName, mode); err == nil { p.dbUpdates <- file @@ -858,7 +865,7 @@ func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocks copyTotal: len(blocks), copyNeeded: len(blocks), reused: reused, - ignorePerms: p.ignorePerms, + ignorePerms: p.ignorePermissions(file), version: curFile.Version, mut: sync.NewMutex(), } @@ -878,7 +885,7 @@ func (p *rwFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocks // thing that has changed. func (p *rwFolder) shortcutFile(file protocol.FileInfo) error { realName := filepath.Join(p.dir, file.Name) - if !p.ignorePerms { + if !p.ignorePermissions(file) { if err := os.Chmod(realName, os.FileMode(file.Flags&0777)); err != nil { l.Infof("Puller (folder %q, file %q): shortcut: chmod: %v", p.folder, file.Name, err) return err @@ -1076,7 +1083,7 @@ func (p *rwFolder) performFinish(state *sharedPullerState) { }() // Set the correct permission bits on the new file - if !p.ignorePerms { + if !p.ignorePermissions(state.file) { err = os.Chmod(state.tempName, os.FileMode(state.file.Flags&0777)) if err != nil { l.Warnln("Puller: final:", err) From 7d48115b9043c13a1f3958718584b6cc9163833f Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 27 May 2015 18:26:43 +0200 Subject: [PATCH 2/9] Reduce db writes for small files We introduced the dbUpdater routine to handle many small files efficiently, but the folder stats call is almost equally expensive as it results in two distinct write transactions to the database. This moves it to the same routine. (Doesn't make a *huge* difference with leveldb actually, but reduces the 50k-files benchmark time by 25% on my experimental bolt branch...) --- internal/model/rwfolder.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/model/rwfolder.go b/internal/model/rwfolder.go index 02d55952b..4274d1091 100644 --- a/internal/model/rwfolder.go +++ b/internal/model/rwfolder.go @@ -1182,7 +1182,6 @@ func (p *rwFolder) finisherRoutine(in <-chan *sharedPullerState) { "action": "update", }) } - p.model.receivedFile(p.folder, state.file.Name) if p.progressEmitter != nil { p.progressEmitter.Deregister(state) } @@ -1228,12 +1227,14 @@ loop: if len(batch) == maxBatchSize { p.model.updateLocals(p.folder, batch) + p.model.receivedFile(p.folder, batch[len(batch)-1].Name) batch = batch[:0] } case <-tick.C: if len(batch) > 0 { p.model.updateLocals(p.folder, batch) + p.model.receivedFile(p.folder, batch[len(batch)-1].Name) batch = batch[:0] } } @@ -1241,6 +1242,7 @@ loop: if len(batch) > 0 { p.model.updateLocals(p.folder, batch) + p.model.receivedFile(p.folder, batch[len(batch)-1].Name) } } From d632e3aa1b2fd971bfb767543ce94159540aadbc Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 27 May 2015 21:54:00 +0200 Subject: [PATCH 3/9] Show help link, add icons, tweak icon spacing --- gui/assets/css/overrides.css | 2 +- gui/assets/lang/lang-en.json | 2 + gui/index.html | 156 +++++++++--------- .../directives/languageSelectDirective.js | 4 +- internal/auto/gui.files.go | 10 +- 5 files changed, 91 insertions(+), 83 deletions(-) diff --git a/gui/assets/css/overrides.css b/gui/assets/css/overrides.css index 4ddc3116d..b2b2d1b96 100644 --- a/gui/assets/css/overrides.css +++ b/gui/assets/css/overrides.css @@ -68,7 +68,7 @@ identicon { } .panel-heading .glyphicon { - margin-right: 15px; + margin-right: 10px; } .panel-heading { diff --git a/gui/assets/lang/lang-en.json b/gui/assets/lang/lang-en.json index 9c816f975..d25501877 100644 --- a/gui/assets/lang/lang-en.json +++ b/gui/assets/lang/lang-en.json @@ -2,6 +2,7 @@ "A new major version may not be compatible with previous versions.": "A new major version may not be compatible with previous versions.", "API Key": "API Key", "About": "About", + "Actions": "Actions", "Add": "Add", "Add Device": "Add Device", "Add Folder": "Add Folder", @@ -62,6 +63,7 @@ "Global Discovery": "Global Discovery", "Global Discovery Server": "Global Discovery Server", "Global State": "Global State", + "Help": "Help", "Ignore": "Ignore", "Ignore Patterns": "Ignore Patterns", "Ignore Permissions": "Ignore Permissions", diff --git a/gui/index.html b/gui/index.html index fee3d7a1e..f11e81ff0 100644 --- a/gui/index.html +++ b/gui/index.html @@ -34,27 +34,33 @@ @@ -73,7 +79,7 @@

The configuration has been saved but not activated. Syncthing must restart to activate the new configuration.

@@ -87,7 +93,7 @@

- New Device +  New Device

@@ -100,9 +106,9 @@
@@ -133,13 +139,13 @@ @@ -157,7 +163,7 @@

{{err.time | date:"yyyy-MM-dd HH:mm:ss"}}: {{friendlyDevices(err.error)}}

@@ -196,51 +202,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - +
Folder Path Folder Path {{folder.path}}
Error Error {{model[folder.id].invalid || model[folder.id].error}}
Global State Global State {{model[folder.id].globalFiles | alwaysNumber}} items, ~{{model[folder.id].globalBytes | binary}}B
Local State Local State {{model[folder.id].localFiles | alwaysNumber}} items, ~{{model[folder.id].localBytes | binary}}B
Out Of Sync Out Of Sync {{model[folder.id].needFiles | alwaysNumber}} items, ~{{model[folder.id].needBytes | binary}}B
Folder Master Folder Master Yes
Ignore Patterns Ignore Patterns Yes
Ignore Permissions Ignore Permissions Yes
Rescan Interval Rescan Interval {{folder.rescanIntervalS}} s
File Pull Order File Pull Order Random Alphabetic @@ -251,7 +257,7 @@
File Versioning File Versioning Staggered File Versioning Simple File Versioning @@ -259,11 +265,11 @@
Shared With Shared With {{sharesFolder(folder)}}
Last File Received Last File Received {{folderStats[folder.id].lastFile.filename | basename}} @@ -274,10 +280,10 @@
@@ -285,8 +291,8 @@ - - + +

@@ -309,23 +315,23 @@ - + - + - + - + - + - + - + @@ -374,53 +380,53 @@
Download Rate Download Rate {{connectionsTotal.inbps | binary}}B/s ({{connectionsTotal.inBytesTotal | binary}}B)
Upload Rate Upload Rate {{connectionsTotal.outbps | binary}}B/s ({{connectionsTotal.outBytesTotal | binary}}B)
RAM Utilization RAM Utilization {{system.sys | binary}}B
CPU Utilization CPU Utilization {{system.cpuPercent | alwaysNumber | natural:1}}%
Global Discovery Global Discovery OK @@ -338,11 +344,11 @@
Uptime Uptime {{system.uptime | duration:"m"}}
Version Version {{versionString()}}
- + - + - + - + - + - + - + - +
Download Rate Download Rate {{connections[deviceCfg.deviceID].inbps | binary}}B/s ({{connections[deviceCfg.deviceID].inBytesTotal | binary}}B)
Upload Rate Upload Rate {{connections[deviceCfg.deviceID].outbps | binary}}B/s ({{connections[deviceCfg.deviceID].outBytesTotal | binary}}B)
Address Address {{deviceAddr(deviceCfg)}}
Compression Compression All Data Off
Introducer Introducer Yes
Version Version {{connections[deviceCfg.deviceID].clientVersion}}
Last seen Last seen Never {{deviceStats[deviceCfg.deviceID].lastSeen | date:"yyyy-MM-dd HH:mm:ss"}}
Folders Folders {{deviceFolders(deviceCfg).join(", ")}}
- +
@@ -433,12 +439,12 @@ @@ -506,8 +512,8 @@

@@ -585,9 +591,9 @@ @@ -750,10 +756,10 @@
When adding a new folder, keep in mind that the Folder ID is used to tie folders together between devices. They are case sensitive and must match exactly between all devices.
@@ -783,8 +789,8 @@ @@ -905,8 +911,8 @@ @@ -927,8 +933,8 @@
{{reportData | json}}
@@ -948,7 +954,7 @@
{{reportData | json}}
@@ -979,7 +985,7 @@ -  {{f.name | basename}} +  {{f.name | basename}} diff --git a/gui/scripts/syncthing/core/directives/languageSelectDirective.js b/gui/scripts/syncthing/core/directives/languageSelectDirective.js index d9815e367..30ba3f0e4 100644 --- a/gui/scripts/syncthing/core/directives/languageSelectDirective.js +++ b/gui/scripts/syncthing/core/directives/languageSelectDirective.js @@ -4,7 +4,7 @@ angular.module('syncthing.core') return { restrict: 'EA', template: - '{{localesNames[currentLocale] || "English"}} '+ + ' {{localesNames[currentLocale] || "English"}} '+ '