mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
Resolve circular import
This commit is contained in:
parent
9ea7fdd8d1
commit
a4f9b485fd
3 changed files with 18 additions and 20 deletions
|
@ -4,6 +4,7 @@ from collections.abc import Generator
|
||||||
from pathlib import Path
|
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 Union
|
from typing import Union
|
||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
|
@ -12,6 +13,22 @@ from .fileops import find_mount
|
||||||
from .logs import logger
|
from .logs import logger
|
||||||
|
|
||||||
|
|
||||||
|
async def get_all_hardlinks(paths: Set[Path]) -> None:
|
||||||
|
for path in paths:
|
||||||
|
if isinstance(path, ShredFile):
|
||||||
|
logger.info("Getting hardlinks for {path}")
|
||||||
|
hardlink_count = 0
|
||||||
|
path.hardlinks = set()
|
||||||
|
async for link in path.fs_handler.get_hardlinks(path):
|
||||||
|
hardlink_count += 1
|
||||||
|
path.hardlinks.add(link)
|
||||||
|
logger.info(f"Found hardlink: {link}")
|
||||||
|
logger.info(f"Found {hardlink_count} hardlinks for {path.absolute_path}")
|
||||||
|
if isinstance(path, ShredDir):
|
||||||
|
await get_all_hardlinks(path)
|
||||||
|
return paths
|
||||||
|
|
||||||
|
|
||||||
class ShredDir:
|
class ShredDir:
|
||||||
"""Class for tracking each directory to be shredded, and its contents."""
|
"""Class for tracking each directory to be shredded, and its contents."""
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,13 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Set
|
|
||||||
|
|
||||||
from asyncstdlib.functools import lru_cache
|
from asyncstdlib.functools import lru_cache
|
||||||
|
|
||||||
from .classes import ShredDir
|
|
||||||
from .classes import ShredFile
|
|
||||||
from .filesystems import FSHandlers
|
from .filesystems import FSHandlers
|
||||||
from .logs import logger
|
from .logs import logger
|
||||||
|
|
||||||
|
|
||||||
async def get_all_hardlinks(paths: Set[Path]) -> None:
|
|
||||||
for path in paths:
|
|
||||||
if isinstance(path, ShredFile):
|
|
||||||
logger.info("Getting hardlinks for {path}")
|
|
||||||
hardlink_count = 0
|
|
||||||
path.hardlinks = set()
|
|
||||||
async for link in path.fs_handler.get_hardlinks(path):
|
|
||||||
hardlink_count += 1
|
|
||||||
path.hardlinks.add(link)
|
|
||||||
logger.info(f"Found hardlink: {link}")
|
|
||||||
logger.info(f"Found {hardlink_count} hardlinks for {path.absolute_path}")
|
|
||||||
if isinstance(path, ShredDir):
|
|
||||||
await get_all_hardlinks(path)
|
|
||||||
return paths
|
|
||||||
|
|
||||||
|
|
||||||
def find_mount(path: Path) -> Path:
|
def find_mount(path: Path) -> Path:
|
||||||
"""Find the mount point for a given path."""
|
"""Find the mount point for a given path."""
|
||||||
path = path.absolute()
|
path = path.absolute()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
from .classes import get_all_hardlinks
|
||||||
from .classes import ShredDir
|
from .classes import ShredDir
|
||||||
from .classes import ShredFile
|
from .classes import ShredFile
|
||||||
from .fileops import get_all_hardlinks
|
|
||||||
from .fileops import mount_to_fs_handler
|
from .fileops import mount_to_fs_handler
|
||||||
from .logs import logger
|
from .logs import logger
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue