syncthing/lib/model
André Colomb e32a516b5f
lib/model: Forget pending folders no longer announced in ClusterConfig (fixes #5187) (#7205)
* lib/db: Add ExpirePendingFolders().

Use-case is to drop any no-longer-pending folders for a specific
device when parsing its ClusterConfig message where previously offered
folders are not mentioned any more.

The timestamp in ObservedFolder is stored with only second precision,
so round to seconds here as well.  This allows calling the function
within the same second of adding or updating entries.

* lib/model: Weed out pending folders when receiving ClusterConfig.

Filter the entries by timestamp, which must be newer than or equal to
the reception time of the ClusterConfig.  For just mentioned ones,
this assumption will hold as AddOrUpdatePendingFolder() updates the
timestamp.

* lib/model, gui: Notify when one or more pending folders expired.

Introduce new event type FolderOfferCancelled and use it to trigger a
complete refreshCluster() cycle.  Listing individual entries would be
much more code and probably just as much work to answer the API
request.

* lib/model: Add comment and rename ExpirePendingFolders().

* lib/events: Rename FolderOfferCancelled to ClusterPendingChanged.

* lib/model: Reuse ClusterPendingChanged event for cleanPending()

Changing the config does not necessarily mean that the
/resut/cluster/pending endpoints need to be refreshed, but only if
something was actually removed.  Detect this and indicate it through
the ClusterPendingChanged event, which is already hooked up to requery
respective endpoints within the GUI.

No more need for a separate refreshCluster() in reaction to
ConfigSaved event or calling refreshConfig().

* lib/model: Gofmt.

* lib/db: Warn instead of info log for failed removal.

* gui: Fix pending notifications not loading on GUI start.

* lib/db: Use short device ID in log message.

* lib/db: Return list of expired folder IDs after deleting them.

* lib/model: Refactor Pending...Changed events.

* lib/model: Adjust format of removed pending folders enumeration.

Use an array of objects with device / folder ID properties, matching
the other places where it's used.

* lib/db: Drop invalid entries in RemovePendingFoldersBeforeTime().

* lib/model: Gofmt.

My local gofmt did not complain here, strangely...

* gui: Handle PendingDevicesChanged event.

Even though it currently only holds one device at a time, wrap the
contents in an array under the "added" property name.

* lib/model: Fix null values in PendingFoldersChanged removed member.

* gui: Handle PendingFoldersChanged event.

* lib/model: Simplify construction of expiredPendingList.

* lib/model: Reduce code duplication in cleanPending().

Use goto and a label for the common parts of calling the DB removal
function and building the event data part.

* lib/events, gui: Mark ...Rejected events deprecated.

Extend comments explaining the conditions when the replacement event
types are emitted.

* lib/model: Wrap removed devices in array of objects as well.

* lib/db: Use iter.Value() instead of needless db.Get(iter.Key())

* lib/db: Add comment explaining RemovePendingFoldersBeforeTime().

* lib/model: Rename fields folderID and deviceID in event data.

* lib/db: Only list actually expired IDs as removed.

Skip entries where Delete() failed as well as invalid entries that got
removed automatically.

* lib/model: Gofmt
2021-01-25 10:58:10 +00:00
..
testdata lib/model: Spurious tmp file (ref #6607) (#6609) 2020-05-07 08:49:59 +02:00
blockpullreorderer_test.go lib/model: Add support for different puller block ordering (#6587) 2020-05-11 22:44:04 +01:00
blockpullreorderer.go lib/model: Add support for different puller block ordering (#6587) 2020-05-11 22:44:04 +01:00
bytesemaphore_test.go lib/model: Allow limiting number of concurrent scans (fixes #2760) (#4888) 2018-12-05 08:40:05 +01:00
bytesemaphore.go lib/model: Don't exit pullerRoutine on cancelled ctx (fixes #6559) (#6562) 2020-04-21 18:55:14 +01:00
debug.go all, lib/logger: Refactor SetDebug calls (#6054) 2019-10-04 13:03:34 +02:00
deviceactivity_test.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
deviceactivity.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
devicedownloadstate_test.go all: Move remaining protos to use the vanity plugin (#7009) 2020-10-02 08:07:05 +02:00
devicedownloadstate.go all: Move remaining protos to use the vanity plugin (#7009) 2020-10-02 08:07:05 +02:00
doc.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
fakeconns_test.go lib: Close underlying conn in protocol (fixes #7165) (#7212) 2020-12-21 11:40:51 +01:00
folder_recvenc.go lib/model: Cleanup redundant filesystem variables in folders (#7237) 2020-12-27 22:26:25 +01:00
folder_recvonly_test.go lib: Apply config changes sequentially (ref #5298) (#7188) 2021-01-15 15:43:34 +01:00
folder_recvonly.go lib/model: Cleanup redundant filesystem variables in folders (#7237) 2020-12-27 22:26:25 +01:00
folder_sendonly.go lib/model: Cleanup redundant filesystem variables in folders (#7237) 2020-12-27 22:26:25 +01:00
folder_sendrecv_test.go lib: Apply config changes sequentially (ref #5298) (#7188) 2021-01-15 15:43:34 +01:00
folder_sendrecv.go lib/model: Fix child-check when deleting dirs in pull (#7236) 2021-01-02 21:40:37 +01:00
folder_summary.go lib/api, lib/model: Avoid contention on filesystem for DB status call (ref #7270) (#7271) 2021-01-12 16:25:21 +01:00
folder_test.go lib/fs: Properly handle case insensitive systems (fixes #1787, fixes #2739, fixes #5708) 2020-07-28 11:15:11 +02:00
folder.go lib/model: Pull when folder leaves error state (fixes #7280) (#7281) 2021-01-14 13:29:01 +01:00
folderstate.go lib/model, lib/versioner: Drive version cleanup from scanner (fixes #6313) (#6693) 2020-07-14 10:48:50 +02:00
indexsender.go lib/model: Handle index sender terminating due to error (fixes #7231) (#7232) 2020-12-30 09:59:11 +01:00
model_test.go lib: Apply config changes sequentially (ref #5298) (#7188) 2021-01-15 15:43:34 +01:00
model.go lib/model: Forget pending folders no longer announced in ClusterConfig (fixes #5187) (#7205) 2021-01-25 10:58:10 +00:00
progressemitter_test.go lib: Apply config changes sequentially (ref #5298) (#7188) 2021-01-15 15:43:34 +01:00
progressemitter.go all: Implement suture v4-api (#6947) 2020-11-17 13:19:04 +01:00
queue_test.go lib/model: Make jobQueue.Jobs paginated (fixes #5754) (#5804) 2019-06-27 19:25:38 +01:00
queue.go lib/model: Make jobQueue.Jobs paginated (fixes #5754) (#5804) 2019-06-27 19:25:38 +01:00
requests_test.go lib: Apply config changes sequentially (ref #5298) (#7188) 2021-01-15 15:43:34 +01:00
sentdownloadstate.go all: Move remaining protos to use the vanity plugin (#7009) 2020-10-02 08:07:05 +02:00
sharedpullerstate_test.go lib/model: Use errors.Wrap for pull errors (#5563) 2019-03-04 13:01:52 +00:00
sharedpullerstate.go lib/model: Fix enc file size when pulling (fixes #7152) (#7155) 2020-11-25 22:57:25 +01:00
testos_test.go lib/fs: Properly handle case insensitive systems (fixes #1787, fixes #2739, fixes #5708) 2020-07-28 11:15:11 +02:00
testutils_test.go lib: Apply config changes sequentially (ref #5298) (#7188) 2021-01-15 15:43:34 +01:00
util.go all: Remove potentially problematic errors from panics (fixes #5839) (#5912) 2019-07-31 10:53:35 +02:00
utils_test.go all: Remove potentially problematic errors from panics (fixes #5839) (#5912) 2019-07-31 10:53:35 +02:00