Changeset 7d8d744 in trunk
- Timestamp:
- 2019-02-26T19:26:37Z (6 years ago)
- Branches:
- master
- Children:
- 9244956
- Parents:
- 248449f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/frontends/magic_folder.py ¶
r248449f r7d8d744 813 813 ) 814 814 815 _STATUS = Field.for_types( 816 u"status", 817 # Should just be unicode... 818 [unicode, bytes], 819 u"The status of an item in a processing queue.", 820 ) 821 822 QUEUED_ITEM_STATUS_CHANGE = MessageType( 823 u"magic-folder:item:status-change", 824 [eliotutil.RELPATH, _STATUS], 825 u"A queued item changed status.", 826 ) 827 828 _CONFLICT_REASON = Field.for_types( 829 u"conflict_reason", 830 [unicode, type(None)], 831 u"A human-readable explanation of why a file was in conflict.", 832 eliotutil.validateSetMembership({ 833 u"dbentry mismatch metadata", 834 u"dbentry newer version", 835 u"last_downloaded_uri mismatch", 836 u"file appeared", 837 }), 838 ) 839 840 CHECKING_CONFLICTS = ActionType( 841 u"magic-folder:item:checking-conflicts", 842 [], 843 [_IS_CONFLICT, _CONFLICT_REASON], 844 u"A potential download item is being checked to determine if it is in a conflicted state.", 845 ) 846 847 REMOTE_DIRECTORY_CREATED = MessageType( 848 u"magic-folder:remote-directory-created", 849 [], 850 u"The downloader found a new directory in the DMD.", 851 ) 852 853 REMOTE_DIRECTORY_DELETED = MessageType( 854 u"magic-folder:remote-directory-deleted", 855 [], 856 u"The downloader found a directory has been deleted from the DMD.", 857 ) 858 815 859 class QueueMixin(HookMixin): 816 860 """ … … 1025 1069 current_time = time.time() 1026 1070 self._status_history[status] = current_time 1071 QUEUED_ITEM_STATUS_CHANGE.log( 1072 relpath=self.relpath_u, 1073 status=status, 1074 ) 1027 1075 1028 1076 def status_time(self, state): … … 1751 1799 self._count("objects_queued") 1752 1800 else: 1753 self._log("Excluding %r" % (relpath_u,))1754 1801 self._call_hook(None, 'processed', async=True) # await this maybe-Deferred?? 1755 1802 1756 self._log("deque after = %r" % (self._deque,))1757 1803 d.addCallback(_filter_batch_to_deque) 1758 1804 return d.addActionFinish() … … 1852 1898 # uploaded. 1853 1899 1854 if db_entry: 1855 # * 2c. If any of the following are true, then classify as a conflict: 1856 # * i. there are pending notifications of changes to ``foo``; 1857 # * ii. the last-seen statinfo is either absent (i.e. there is 1858 # no entry in the database for this path), or different from the 1859 # current statinfo; 1860 1861 if current_statinfo.exists: 1862 self._log("checking conflicts {}".format(item.relpath_u)) 1863 if (db_entry.mtime_ns != current_statinfo.mtime_ns or \ 1864 db_entry.ctime_ns != current_statinfo.ctime_ns or \ 1865 db_entry.size != current_statinfo.size): 1900 with CHECKING_CONFLICTS() as action: 1901 if db_entry: 1902 # * 2c. If any of the following are true, then classify as a conflict: 1903 # * i. there are pending notifications of changes to ``foo``; 1904 # * ii. the last-seen statinfo is either absent (i.e. there is 1905 # no entry in the database for this path), or different from the 1906 # current statinfo; 1907 1908 if current_statinfo.exists: 1909 conflict_reason = None 1910 if (db_entry.mtime_ns != current_statinfo.mtime_ns or \ 1911 db_entry.ctime_ns != current_statinfo.ctime_ns or \ 1912 db_entry.size != current_statinfo.size): 1913 is_conflict = True 1914 conflict_reason = u"dbentry mismatch metadata" 1915 1916 if db_entry.last_downloaded_uri is None \ 1917 or db_entry.last_uploaded_uri is None \ 1918 or dmd_last_downloaded_uri is None: 1919 # we've never downloaded anything before for this 1920 # file, but the other side might have created a new 1921 # file "at the same time" 1922 if db_entry.version >= item.metadata['version']: 1923 is_conflict = True 1924 conflict_reason = u"dbentry newer version" 1925 elif dmd_last_downloaded_uri != db_entry.last_downloaded_uri: 1926 is_conflict = True 1927 conflict_reason = u"last_downloaded_uri mismatch" 1928 1929 else: # no local db_entry .. but has the file appeared locally meantime? 1930 if current_statinfo.exists: 1866 1931 is_conflict = True 1867 self._log("conflict because local change0") 1868 1869 if db_entry.last_downloaded_uri is None \ 1870 or db_entry.last_uploaded_uri is None \ 1871 or dmd_last_downloaded_uri is None: 1872 # we've never downloaded anything before for this 1873 # file, but the other side might have created a new 1874 # file "at the same time" 1875 if db_entry.version >= item.metadata['version']: 1876 self._log("conflict because my version >= remote version") 1877 is_conflict = True 1878 elif dmd_last_downloaded_uri != db_entry.last_downloaded_uri: 1879 is_conflict = True 1880 self._log("conflict because dmd_last_downloaded_uri != db_entry.last_downloaded_uri") 1881 1882 else: # no local db_entry .. but has the file appeared locally meantime? 1883 if current_statinfo.exists: 1884 is_conflict = True 1885 self._log("conflict because local change1") 1932 conflict_reason = u"file appeared" 1933 1934 action.add_success_fields( 1935 is_conflict=is_conflict, 1936 conflict_reason=conflict_reason, 1937 ) 1886 1938 1887 1939 if is_conflict: … … 1890 1942 if item.relpath_u.endswith(u"/"): 1891 1943 if item.metadata.get('deleted', False): 1892 self._log("rmdir(%r) ignored" % (abspath_u,))1944 REMOTE_DIRECTORY_DELETED.log() 1893 1945 else: 1894 self._log("mkdir(%r)" % (abspath_u,))1946 REMOTE_DIRECTORY_CREATED.log() 1895 1947 d.addCallback(lambda ign: fileutil.make_dirs(abspath_u)) 1896 1948 d.addCallback(lambda ign: abspath_u) … … 1913 1965 def trap_conflicts(f): 1914 1966 f.trap(ConflictError) 1915 self._log("IGNORE CONFLICT ERROR %r" % f)1916 1967 return False 1917 1968 d.addErrback(trap_conflicts)
Note: See TracChangeset
for help on using the changeset viewer.