From 554c506745cd5782a7bca83f75a729839972b9d7 Mon Sep 17 00:00:00 2001 From: Levi-Hope <117010292@link.cuhk.edu.cn> Date: Fri, 23 Jul 2021 03:29:10 +0800 Subject: [PATCH 1/3] cryptcheck: agnostify src dst order --- cmd/cryptcheck/cryptcheck.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/cryptcheck/cryptcheck.go b/cmd/cryptcheck/cryptcheck.go index b803beb5dbd43..d9729692513ce 100644 --- a/cmd/cryptcheck/cryptcheck.go +++ b/cmd/cryptcheck/cryptcheck.go @@ -57,11 +57,16 @@ After it has run it will log the status of the encryptedremote:. // cryptCheck checks the integrity of a crypted remote func cryptCheck(ctx context.Context, fdst, fsrc fs.Fs) error { - // Check to see fcrypt is a crypt + // Check to see fdst is crypted. If not, check fsrc. fcrypt, ok := fdst.(*crypt.Fs) if !ok { - return errors.Errorf("%s:%s is not a crypt remote", fdst.Name(), fdst.Root()) + fcrypt, ok = fsrc.(*crypt.Fs) + if !ok { + return errors.Errorf("Both %s:%s and %s:%s are not crypt remote", fsrc.Name(), fsrc.Root(), fdst.Name(), fdst.Root()) + } + fdst, fsrc = fsrc, fdst } + // Find a hash to use funderlying := fcrypt.UnWrap() hashType := funderlying.Hashes().GetOne() From 5a3961227fdac680b0c266606e6154ab47fe905d Mon Sep 17 00:00:00 2001 From: Levi-Hope <117010292@link.cuhk.edu.cn> Date: Fri, 23 Jul 2021 04:13:27 +0800 Subject: [PATCH 2/3] cryptcheck: add more log --- cmd/cryptcheck/cryptcheck.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/cryptcheck/cryptcheck.go b/cmd/cryptcheck/cryptcheck.go index d9729692513ce..1cbca710b8f61 100644 --- a/cmd/cryptcheck/cryptcheck.go +++ b/cmd/cryptcheck/cryptcheck.go @@ -64,6 +64,7 @@ func cryptCheck(ctx context.Context, fdst, fsrc fs.Fs) error { if !ok { return errors.Errorf("Both %s:%s and %s:%s are not crypt remote", fsrc.Name(), fsrc.Root(), fdst.Name(), fdst.Root()) } + fs.Infof(nil, "Dst %s:%s is not a crypt remote, switching src and dst", fdst.Name(), fdst.Root()) fdst, fsrc = fsrc, fdst } From 991c31508e8b31e01cc90f25f13a36183c1dc325 Mon Sep 17 00:00:00 2001 From: Levi-Hope <117010292@link.cuhk.edu.cn> Date: Fri, 23 Jul 2021 16:32:52 +0800 Subject: [PATCH 3/3] cryptcheck:increase log level --- cmd/cryptcheck/cryptcheck.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cryptcheck/cryptcheck.go b/cmd/cryptcheck/cryptcheck.go index 1cbca710b8f61..c577fb437ca60 100644 --- a/cmd/cryptcheck/cryptcheck.go +++ b/cmd/cryptcheck/cryptcheck.go @@ -62,9 +62,9 @@ func cryptCheck(ctx context.Context, fdst, fsrc fs.Fs) error { if !ok { fcrypt, ok = fsrc.(*crypt.Fs) if !ok { - return errors.Errorf("Both %s:%s and %s:%s are not crypt remote", fsrc.Name(), fsrc.Root(), fdst.Name(), fdst.Root()) + return errors.Errorf("Both %s:%s and %s:%s are not crypt remote", fdst.Name(), fdst.Root(), fsrc.Name(), fsrc.Root()) } - fs.Infof(nil, "Dst %s:%s is not a crypt remote, switching src and dst", fdst.Name(), fdst.Root()) + fs.Logf(nil, "%s:%s is not a crypt remote, using %s:%s as dst", fdst.Name(), fdst.Root(), fsrc.Name(), fsrc.Root()) fdst, fsrc = fsrc, fdst }