aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/Drop_--from_always_trusts_local_repository.mdwn
blob: 53bdda3328d43c42861888ce6bf98740873cc6d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
### Please describe the problem.

The command `git annex drop --from` always trusts the local repository, even if
it is marked as untrusted.


### What steps will reproduce the problem?
[[!format sh """
mkdir t u; cd t; git init; git commit --allow-empty -m "Initial commit"; git annex init "Trusted"; date > file; git annex add file; git commit -m "Add file"; cd ../u; git init; git remote add t ../t; git fetch t; git merge t/master; git annex init "Untrusted"; git annex untrust .; git annex get file; cd ../t; git remote add u ../u; git fetch u; cd ..
"""]]

Create two repositories, *t* (trusted) and *u* (untrusted). A file is in both
repositories. When performing `git annex drop file` in repository *t*, `git
annex` will abort because there are not enough copies. But when performing `git
annex drop --from t file` in *u*, git annex will delete the copy.


### What version of git-annex are you using? On what operating system?

Bug was introduced with 6c31e3a8 and still exists in current master (d955cfe7).


### Please provide any additional information below.

The following change seems to solve the problem. (First time working with
Haskell, please excuse the crude code.)

[[!format diff """
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 269c4c2..09ea99a 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -82,8 +82,9 @@ performRemote key afile numcopies remote = lockContent key $ do
        (remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
        present <- inAnnex key
        u <- getUUID
+       level <- lookupTrust u
        let have = filter (/= uuid) $
-               if present then u:trusteduuids else trusteduuids
+               if present && level <= SemiTrusted then u:trusteduuids else trusteduuids
        untrusteduuids <- trustGet UnTrusted
        let tocheck = filter (/= remote) $
                Remote.remotesWithoutUUID remotes (have++untrusteduuids)
"""]]

> [[fixed|done]] --[[Joey]]