[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][master] 2 commits: generate-index-diffs: Resolve files before linking them



Title: GitLab

Ansgar pushed to branch master at Debian FTP Team / dak

Commits:

1 changed file:

Changes:

  • dak/generate_index_diffs.py
    ... ... @@ -123,9 +123,17 @@ def genchanges(Options, outdir, oldfile, origfile, maxdiffs=56):
    123 123
         if not origstat:
    
    124 124
             print("%s: doesn't exist" % (origfile))
    
    125 125
             return
    
    126
    +    # orig file with the (new) compression extension in case it changed
    
    127
    +    old_full_path = oldfile + origext
    
    128
    +    resolved_orig_path = os.path.realpath(origfile + origext)
    
    129
    +
    
    126 130
         if not oldstat:
    
    127
    -        print("%s: initial run" % (origfile))
    
    128
    -        os.link(origfile + origext, oldfile + origext)
    
    131
    +        print("%s: initial run" % origfile)
    
    132
    +        # The target file might have been copying over the symlink as an accident
    
    133
    +        # in a previous run.
    
    134
    +        if os.path.islink(old_full_path):
    
    135
    +            os.unlink(old_full_path)
    
    136
    +        os.link(resolved_orig_path, old_full_path)
    
    129 137
             return
    
    130 138
     
    
    131 139
         if oldstat[1:3] == origstat[1:3]:
    
    ... ... @@ -156,8 +164,13 @@ def genchanges(Options, outdir, oldfile, origfile, maxdiffs=56):
    156 164
     
    
    157 165
         upd.update_index()
    
    158 166
     
    
    167
    +    if oldfile + oldext != old_full_path and os.path.islink(old_full_path):
    
    168
    +        # The target file might have been copying over the symlink as an accident
    
    169
    +        # in a previous run.
    
    170
    +        os.unlink(old_full_path)
    
    171
    +
    
    159 172
         os.unlink(oldfile + oldext)
    
    160
    -    os.link(origfile + origext, oldfile + origext)
    
    173
    +    os.link(resolved_orig_path, old_full_path)
    
    161 174
     
    
    162 175
     
    
    163 176
     def main():
    


  • Reply to: