summaryrefslogtreecommitdiff
path: root/doc/todo/New_special_remote_suggeston_-_clean_directory/comment_9_0ba57952532d5ef1f2bbfb163faa3b2f._comment
blob: d96ac69870e0dad4f164fe7ce21fea1743004355 (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
[[!comment format=mdwn
 username="https://www.google.com/accounts/o8/id?id=AItOawmicVKRM8vJX4wPuAwlLEoS2cjmFXQkjkE"
 nickname="Thomas"
 subject="pseudocode"
 date="2013-12-08T15:23:36Z"
 content="""
The implementation should really be nothing more than the following to be run from a regular git annex repository with a configures special plain directory remote:

    foreach(path : allAnnexedFiles) {
      if(remote.exists(path) && remote.filesize(path) === expectedFilesize) goto finally;
    
      if(fileAvailableLocally(path)) {
        copyFileToRemote(path);
        goto finally;
      }

      if(shouldCopyFromElsewhere && canCopyFileFromSomeOtherRemote(path)) {
        copyFileFromSomeOtherRemoteToRemote(path);
      }

      finally: 
        logThatFileExistsOnRemote(path);
    }
    
    foreach(remotePath : filesInRemoteDir) {
      if(fileIsAnnexed(remotePath) || fileIsIgnored(remotePath) continue;
    
      delete(remotePath);
    }

The above pseude code assumes
- that the no other process is working on the remote at the same time.
- that the remote is not trusted.
- that nobody expects changes done at the remote to propagate to other clones.
"""]]