mirror of
https://codeberg.org/vlw/cloud-backup.git
synced 2025-09-14 01:53:42 +02:00
30 lines
No EOL
677 B
Python
30 lines
No EOL
677 B
Python
import os
|
|
import zlib
|
|
|
|
from ..db import dbname
|
|
|
|
class FileSystem:
|
|
def __init__(self):
|
|
self.path = FileSystem.get_path()
|
|
|
|
@staticmethod
|
|
def get_path() -> str:
|
|
return os.getenv("SOURCE_FOLDER")
|
|
|
|
@staticmethod
|
|
def chksum(data: str) -> str:
|
|
return zlib.crc32(data)
|
|
|
|
# Get metadata from candidate file or folder
|
|
def make_obj(self, anchor: str) -> list:
|
|
mtime = os.path.getmtime(anchor)
|
|
if os.path.isdir(anchor):
|
|
|
|
|
|
data = [anchor, mtime, chksum]
|
|
return obj
|
|
|
|
def all(self) -> list:
|
|
content = os.listdir(self.path)
|
|
content = list(map(self.make_obj, content))
|
|
return content |