Skip to content

Commit bf59c44

Browse files
committed
chore: 减少对存储的压力
1 parent fb28225 commit bf59c44

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

core/storages/alist.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ async def write_file(self, file: MeasureFile | File, content: io.BytesIO):
247247
}
248248
)
249249
if result.code == 200:
250+
info = await self.__info_file(file)
250251
self.filelist[path] = FileInfo(
251-
result.data["size"],
252-
utils.parse_isotime_to_timestamp(result.data["modified"])
252+
info.size,
253+
info.modified
253254
)
254255
return result.code == 200
255256

@@ -271,7 +272,15 @@ async def exists(self, file: MeasureFile | File) -> bool:
271272
return path in self.filelist
272273

273274
async def get_mtime(self, file: MeasureFile | File) -> float:
274-
return (await self.__info_file(file)).modified
275+
path = str(self.get_path(file))
276+
if path in self.filelist:
277+
return self.filelist[path].mtime
278+
info = await self.__info_file(file)
279+
self.filelist[path] = FileInfo(
280+
info.size,
281+
info.modified
282+
)
283+
return info.modified
275284

276285
async def get_size(self, file: MeasureFile | File) -> int:
277286
path = str(self.get_path(file))

core/storages/webdav.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,15 @@ async def _info_file(self, file: CollectionFile) -> WebDavFileInfo:
153153
return result
154154

155155
async def get_mtime(self, file: MeasureFile | File) -> float:
156-
return (await self._info_file(file)).modified
156+
path = str(self.get_path(file))
157+
if path in self.filelist:
158+
return self.filelist[path].mtime
159+
info = await self._info_file(file)
160+
self.filelist[path] = FileInfo(
161+
size=info.size,
162+
mtime=info.modified,
163+
)
164+
return info.modified
157165

158166
async def get_size(self, file: MeasureFile | File) -> int:
159167
path = str(self.get_path(file))

0 commit comments

Comments
 (0)