resolve() is broken in aiopath

hacky fix for now
This commit is contained in:
Darryl Nixon 2023-07-16 13:35:47 -07:00
parent b61e16130d
commit 04bce50fb9

View file

@ -1,6 +1,7 @@
import asyncio import asyncio
import hashlib import hashlib
from collections.abc import Generator from collections.abc import Generator
from pathlib import Path
from secrets import token_bytes from secrets import token_bytes
from typing import List from typing import List
from typing import Set from typing import Set
@ -28,7 +29,9 @@ class ShredDir(AsyncObject):
"""Class for tracking each directory to be shredded, and its contents.""" """Class for tracking each directory to be shredded, and its contents."""
async def __init__(self, path: AsyncPath, recursive: bool) -> None: async def __init__(self, path: AsyncPath, recursive: bool) -> None:
self.absolute_path = await (await path.resolve()).absolute() # https://github.com/alexdelorenzo/aiopath/issues/30 :(
resolved = AsyncPath(Path(path).resolve())
self.absolute_path = await resolved.absolute()
self.mount_point = await find_mount(self.absolute_path) self.mount_point = await find_mount(self.absolute_path)
self.contents = await self._get_contents(recursive) self.contents = await self._get_contents(recursive)
self.mount_points = set(m for m in self.enumerate_mount_points()) self.mount_points = set(m for m in self.enumerate_mount_points())
@ -87,7 +90,9 @@ class ShredFile(AsyncObject):
"""Class for tracking each file to be shredded.""" """Class for tracking each file to be shredded."""
async def __init__(self, path: AsyncPath) -> None: async def __init__(self, path: AsyncPath) -> None:
self.absolute_path = await (await path.resolve()).absolute() # https://github.com/alexdelorenzo/aiopath/issues/30 :(
resolved = AsyncPath(Path(path).resolve())
self.absolute_path = await resolved.absolute()
stat = await path.stat() stat = await path.stat()
self.byte_size = stat.st_size self.byte_size = stat.st_size
self.inode = stat.st_ino self.inode = stat.st_ino