1
mirror of https://github.com/rclone/rclone synced 2024-11-21 22:50:16 +01:00
rclone/lib
nielash 9b4b3033da fs/cache: fix parent not getting pinned when remote is a file
Before this change, when cache.GetFn was called on a file rather than a
directory, two cache entries would be added (the file + its parent) but only one
of them would get pinned if the caller then called Pin(f). This left the other
one exposed to expiration if the ci.FsCacheExpireDuration was reached. This was
problematic because both entries point to the same Fs, and if one entry expires
while the other is pinned, the Shutdown method gets erroneously called on an Fs
that is still in use.

An example of the problem showed up in the Hasher backend, which uses the
Shutdown method to stop the bolt db used to store hashes. If a command was run
on a Hasher file (ex. `rclone md5sum --download hasher:somelargefile.zip`) and
hashing the file took longer than the --fs-cache-expire-duration (5m by default), the
bolt db was stopped before the hashing operation completed, resulting in an
error.

This change fixes the issue by ensuring that:
1. only one entry is added to the cache (the file's parent, not the file).
2. future lookups correctly find the entry regardless of whether they are called
	with the parent name or one of its children.
3. fs.ErrorIsFile is returned when (and only when) fsString points to a file
	(preserving the fix from 8d5bc7f28b).

Note that f.Root() should always point to the parent dir as of c69eb84573
2024-09-28 13:49:56 +01:00
..
atexit build: remove build constraint syntax for go 1.16 and older 2024-04-18 16:53:55 +02:00
batcher docs: fix typo in batcher docs for dropbox and googlephotos 2024-07-24 10:58:22 +01:00
bucket bucket: add Join function for a simplified path.Join 2023-03-03 15:51:00 +00:00
buildinfo build: fix gocritic lint issue unslice 2024-08-15 22:08:34 +01:00
cache fs/cache: fix parent not getting pinned when remote is a file 2024-09-28 13:49:56 +01:00
daemonize build: fix gocritic lint issue wrapperfunc 2024-08-15 22:08:34 +01:00
debug build: update to go1.21rc3 and make go1.19 the minimum required version 2023-07-16 10:09:25 +01:00
dircache build: fix gocritic lint issue elseif 2024-08-15 22:08:34 +01:00
diskusage Add lib/diskusage to measure used/free on disks 2023-09-07 15:57:45 +01:00
encoder build: update logging statements to make json log work - fixes #6038 2024-09-06 17:04:18 +01:00
env docs: punctuation cleanup 2021-10-20 22:56:19 +02:00
errcount errcount: factor errcount abstraction from operations 2024-02-22 11:13:54 +00:00
errors lib: fix typos found by codespell 2023-03-24 20:40:52 +00:00
exitcode cmd: change exit code from 1 to 2 for syntax and usage errors 2024-09-20 18:51:08 +02:00
file lib/file: use builtin MkdirAll with go1.22 instead of our own custom version for windows 2024-09-02 18:16:38 +02:00
http lib/sd-activation: wrap coreos/go-systemd 2024-09-06 17:21:56 +01:00
israce build: remove build constraint syntax for go 1.16 and older 2024-04-18 16:53:55 +02:00
jwtutil build: fix govet lint errors with golangci-lint v1.60.1 2024-08-14 18:25:40 +01:00
kv build: fix linting issues reported by running golangci-lint with different GOOS 2024-04-22 19:29:12 +02:00
mmap lib/mmap: fix lint error on deprecated reflect.SliceHeader 2024-07-20 10:54:47 +01:00
multipart multipart: make pool buffer size public 2024-08-14 21:13:09 +01:00
oauthutil oauthutil: clear client secret if client ID is set 2024-05-11 16:03:32 +01:00
pacer amazonclouddrive: remove Amazon Drive backend code and docs #7539 2024-01-04 17:05:54 +00:00
plugin build: remove build constraint syntax for go 1.16 and older 2024-04-18 16:53:55 +02:00
pool build: update logging statements to make json log work - fixes #6038 2024-09-06 17:04:18 +01:00
proxy build: fix lint errors when re-enabling revive exported & package-comments 2023-08-29 13:03:13 +01:00
random random: update Password docs 2024-04-25 11:14:14 +01:00
ranges refactor: replace min/max helpers with built-in min/max 2024-08-17 13:09:44 +02:00
readers ftp: fix multi-thread copy 2024-01-03 12:21:08 +00:00
rest build: fix gosimple lint errors with golangci-lint v1.60.1 2024-08-14 17:46:12 +01:00
sdactivation lib/sd-activation: wrap coreos/go-systemd 2024-09-06 17:21:56 +01:00
structs test: do not test deprecated and unused Dial and DialTLS functions on http Transport type 2023-03-26 14:28:15 +02:00
systemd build: update logging statements to make json log work - fixes #6038 2024-09-06 17:04:18 +01:00
terminal build: fix govet lint errors with golangci-lint v1.60.1 2024-08-14 18:25:40 +01:00
version Fix lint issues reported by staticcheck 2022-06-13 21:13:50 +02:00