Changeset 47b1787 in trunk
- Timestamp:
- 2018-04-30T20:55:51Z (7 years ago)
- 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)
- Location:
- src/allmydata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/frontends/magic_folder.py ¶
re000047 r47b1787 991 991 precondition_abspath(abspath_u) 992 992 replacement_path_u = abspath_u + u".tmp" # FIXME more unique 993 backup_path_u = abspath_u + u".backup"994 993 if now is None: 995 994 now = time.time() … … 1012 1011 else: 1013 1012 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) 1026 1014 return abspath_u 1027 1015 except fileutil.ConflictError: -
TabularUnified src/allmydata/util/fileutil.py ¶
re000047 r47b1787 614 614 os.rename(source_path, dest_path) 615 615 616 def replace_file(replaced_path, replacement_path , backup_path):616 def replace_file(replaced_path, replacement_path): 617 617 precondition_abspath(replaced_path) 618 618 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, 622 623 REPLACEFILE_IGNORE_MERGE_ERRORS, None, None) 623 624 if r == 0: … … 641 642 reraise(UnableToUnlinkReplacementError) 642 643 643 def replace_file(replaced_path, replacement_path , backup_path):644 def replace_file(replaced_path, replacement_path): 644 645 precondition_abspath(replaced_path) 645 646 precondition_abspath(replacement_path) 646 precondition_abspath(backup_path)647 647 648 648 if not os.path.exists(replacement_path): 649 649 raise ConflictError("Replacement file not found: %r" % (replacement_path,)) 650 650 651 try:652 os.rename(replaced_path, backup_path)653 except OSError as e:654 if e.errno != ENOENT:655 raise656 651 try: 657 652 rename_no_overwrite(replacement_path, replaced_path)
Note: See TracChangeset
for help on using the changeset viewer.