Changeset 47b1787 in trunk


Ignore:
Timestamp:
2018-04-30T20:55:51Z (7 years ago)
Author:
meejah <meejah@…>
Branches:
master
Children:
affb80e
Parents:
e000047
git-author:
meejah <meejah@…> (2018-03-21 18:15:11)
git-committer:
meejah <meejah@…> (2018-04-30 20:55:51)
Message:

stop writing .backup files for normal overwrites

Location:
src/allmydata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/frontends/magic_folder.py

    re000047 r47b1787  
    991991        precondition_abspath(abspath_u)
    992992        replacement_path_u = abspath_u + u".tmp"  # FIXME more unique
    993         backup_path_u = abspath_u + u".backup"
    994993        if now is None:
    995994            now = time.time()
     
    10121011        else:
    10131012            try:
    1014                 # XXX this is wrong; I think we're right now *always*
    1015                 # creating a .backup file if we a) downloaded
    1016                 # something and b) we already had a file.
    1017                 # so if you have alice + bob and file0:
    1018                 # - alice adds file0
    1019                 # - bob downloads file0
    1020                 # - alice changes file0
    1021                 # - bob downloads file0 (and creates file0.backup)
    1022                 # - alice changes file0
    1023                 # - bob downloads file0 (tries to create file0.backup, then makes file0.conflict)
    1024 
    1025                 fileutil.replace_file(abspath_u, replacement_path_u, backup_path_u)
     1013                fileutil.replace_file(abspath_u, replacement_path_u)
    10261014                return abspath_u
    10271015            except fileutil.ConflictError:
  • TabularUnified src/allmydata/util/fileutil.py

    re000047 r47b1787  
    614614        os.rename(source_path, dest_path)
    615615
    616     def replace_file(replaced_path, replacement_path, backup_path):
     616    def replace_file(replaced_path, replacement_path):
    617617        precondition_abspath(replaced_path)
    618618        precondition_abspath(replacement_path)
    619         precondition_abspath(backup_path)
    620 
    621         r = ReplaceFileW(replaced_path, replacement_path, backup_path,
     619
     620        # no "backup" path (the first None) because we don't want to
     621        # create a backup file
     622        r = ReplaceFileW(replaced_path, replacement_path, None,
    622623                         REPLACEFILE_IGNORE_MERGE_ERRORS, None, None)
    623624        if r == 0:
     
    641642            reraise(UnableToUnlinkReplacementError)
    642643
    643     def replace_file(replaced_path, replacement_path, backup_path):
     644    def replace_file(replaced_path, replacement_path):
    644645        precondition_abspath(replaced_path)
    645646        precondition_abspath(replacement_path)
    646         precondition_abspath(backup_path)
    647647
    648648        if not os.path.exists(replacement_path):
    649649            raise ConflictError("Replacement file not found: %r" % (replacement_path,))
    650650
    651         try:
    652             os.rename(replaced_path, backup_path)
    653         except OSError as e:
    654             if e.errno != ENOENT:
    655                 raise
    656651        try:
    657652            rename_no_overwrite(replacement_path, replaced_path)
Note: See TracChangeset for help on using the changeset viewer.