Skip to content

Commit cb4a8dc

Browse files
authored
Merge pull request #60 from TTB-Network/dev/master
回滚一些代码
2 parents 0080f03 + 0f1df03 commit cb4a8dc

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

core/cluster.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def __init__(self, name: str, dir: Path, width: int) -> None:
521521
if self.dir.is_file():
522522
raise FileExistsError(f"Cannot copy file: '{self.dir}': Is a file.")
523523
self.dir.mkdir(exist_ok=True, parents=True)
524-
self.cache: CacheManager = CacheManager(FileType.LOCAL, FileContentType.DATA if CACHE_ENABLE else FileContentType.PATH)
524+
self.cache: dict[str, File] = {}
525525
self.timer = scheduler.repeat(
526526
self.clear_cache, delay=CHECK_CACHE, interval=CHECK_CACHE
527527
)
@@ -902,7 +902,7 @@ async def write(self, hash: str, io: io.BytesIO) -> int:
902902
path = self._file_endpoint(f"{hash[:2]}/{hash}")
903903
await self._mkdir(self._file_endpoint(f"{hash[:2]}"))
904904
await self._execute(self.session.upload_to(io.getbuffer(), path))
905-
self.files[hash] = File(path, hash, len(io.getbuffer()))
905+
self.files[hash] = File(path, hash, len(io.getbuffer()), FileContentType.URL)
906906
return self.files[hash].size
907907

908908
async def get_files(self, dir: str) -> list[str]:
@@ -1341,27 +1341,10 @@ async def message(self, channel, data: list[Any], callback=None):
13411341
logger.error(traceback.format_exc())
13421342

13431343

1344-
class CacheManager:
1345-
def __init__(self, type: FileType, data: FileContentType):
1346-
self.type = type
1347-
self.data = data
1348-
self.cache: dict[str, File] = {}
1349-
1350-
def set(self, key: str, value: File) -> File:
1351-
self.cache[key] = value
1352-
return value
1353-
1354-
def get_or_default(self, key: str) -> Optional[File]:
1355-
if key not in self.cache:
1356-
return None
1357-
return self.cache[key]
1358-
1359-
13601344
token = TokenManager()
13611345
cluster: Optional[Cluster] = None
13621346
last_status: str = "-"
13631347
storages = StorageManager()
1364-
cache: CacheManager = CacheManager()
13651348

13661349

13671350
async def init():

0 commit comments

Comments
 (0)