Changeset 1b8ae80 in trunk
- Timestamp:
- 2021-11-30T23:01:15Z (3 years ago)
- Branches:
- master
- Children:
- 0a4bc38
- Parents:
- 3fd1ca8a
- Location:
- src/allmydata/storage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/storage/crawler.py ¶
r3fd1ca8a r1b8ae80 109 109 pickle-style state into JSON-style state 110 110 111 :returns unicode: the local path where the state is stored111 :returns FilePath: the local path where the state is stored 112 112 113 113 If this state path is JSON, simply return it. … … 117 117 """ 118 118 if state_path.path.endswith(".json"): 119 return state_path .path119 return state_path 120 120 121 121 json_state_path = state_path.siblingExtension(".json") … … 124 124 # nothing to upgrade 125 125 if not state_path.exists(): 126 return json_state_path .path126 return json_state_path 127 127 128 128 # upgrade the pickle data to JSON … … 136 136 # we've written the JSON, delete the pickle 137 137 state_path.remove() 138 return json_state_path.path 138 return json_state_path 139 140 141 def _confirm_json_format(fp): 142 """ 143 :param FilePath fp: the original (pickle) name of a state file 144 145 This confirms that we do _not_ have the pickle-version of a 146 state-file and _do_ either have nothing, or the JSON version. If 147 the pickle-version exists, an exception is raised. 148 149 :returns FilePath: the JSON name of a state file 150 """ 151 jsonfp = fp.siblingExtension(".json") 152 if fp.exists(): 153 raise MigratePickleFileError(fp) 154 return jsonfp 139 155 140 156 … … 147 163 148 164 def __init__(self, state_path): 149 self._path = FilePath( 150 _maybe_upgrade_pickle_to_json( 151 FilePath(state_path), 152 _convert_pickle_state_to_json, 153 ) 154 ) 165 self._path = _confirm_json_format(FilePath(state_path)) 155 166 156 167 def load(self): -
TabularUnified src/allmydata/storage/expirer.py ¶
r3fd1ca8a r1b8ae80 13 13 from allmydata.storage.crawler import ( 14 14 ShareCrawler, 15 MigratePickleFileError, 16 _confirm_json_format, 15 17 _maybe_upgrade_pickle_to_json, 16 18 _convert_cycle_data, … … 41 43 """ 42 44 Serialize the 'history' file of the lease-crawler state. This is 43 "storage/ history.state" for the pickle or44 "storage/ history.state.json" for the new JSON format.45 "storage/lease_checker.history" for the pickle or 46 "storage/lease_checker.history.json" for the new JSON format. 45 47 """ 46 48 47 49 def __init__(self, history_path): 48 self._path = FilePath( 49 _maybe_upgrade_pickle_to_json( 50 FilePath(history_path), 51 _convert_pickle_state_to_json, 52 ) 53 ) 50 self._path = _confirm_json_format(FilePath(history_path)) 51 54 52 if not self._path.exists(): 55 53 with self._path.open("wb") as f:
Note: See TracChangeset
for help on using the changeset viewer.