rclone/fs/rc
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
..
jobs rc: convert options to new style 2024-07-15 11:09:54 +01:00
js build: remove build constraint syntax for go 1.16 and older 2024-04-18 16:53:55 +02:00
rcflags rc: convert options to new style 2024-07-15 11:09:54 +01:00
rcserver rc: fix default value of --metrics-addr 2024-09-13 15:52:51 +01:00
webgui rc: convert options to new style 2024-07-15 11:09:54 +01:00
cache_test.go fs/cache: fix parent not getting pinned when remote is a file 2024-09-28 13:49:56 +01:00
cache.go rc: Add GetFsNamedFileOK to get an fs which could also be a file 2024-02-29 16:21:42 +00:00
config_test.go rc: add option blocks parameter to options/get and options/info 2024-07-16 15:02:50 +01:00
config.go rc: add option blocks parameter to options/get and options/info 2024-07-16 15:02:50 +01:00
internal_test.go rc: fix core/command giving 500 internal error - fixes #4914 2021-01-10 16:34:46 +00:00
internal.go build: fix govet lint errors with golangci-lint v1.60.1 2024-08-14 18:25:40 +01:00
params_test.go Remove github.com/pkg/errors and replace with std library version 2021-11-07 11:53:30 +00:00
params.go cmd/mountlib: convert time.Duration option to fs.Duration 2024-07-15 11:09:54 +01:00
rc_test.go fs/rc: add more infrastructure to help writing rc functions 2018-11-02 17:32:20 +00:00
rc.go rc: fix default value of --metrics-addr 2024-09-13 15:52:51 +01:00
registry.go config: fixed issues with flags/options set by environment vars. 2021-07-05 16:38:20 +01:00