lazydata/storage/local.py
def store_file(self, path:str):
        """
        Store a file in the local backend.

        :ivar path: The path to the file to store
        :return:
        """

        stat = os.stat(path)
        abspath = Path(path).resolve()

        sha256 = calculate_file_sha256(path)

        # see if we stored this file already
        datapath = self.hash_to_file(sha256)

        # copy over the the cache,
        # TODO: option to hardlink
        datapath.parent.mkdir(parents=True, exist_ok=True)
        if not datapath.exists():
            shutil.copyfile(str(abspath), str(datapath))

        # Store in the metadata DB if doesn't exist already
        existing_entries = DataFile.select().where(
            (
                (DataFile.abspath == abspath) &
                (DataFile.sha256 == sha256) &
                (DataFile.mtime == stat.st_mtime) &
                (DataFile.size == stat.st_size)
            )
        )

        if existing_entries.count() == 0:
            DataFile.create(abspath=abspath, sha256=sha256, mtime=stat.st_mtime, size=stat.st_size)

        Store a file in the local backend.

        :ivar path: The path to the file to store
        :return:
        
Store a file in the local backend.
Store a file in the local backend .
def store_file(self, path:str):
        stat = os.stat(path)
        abspath = Path(path).resolve()
        sha256 = calculate_file_sha256(path)
        datapath = self.hash_to_file(sha256)
        datapath.parent.mkdir(parents=True, exist_ok=True)
        if not datapath.exists():
            shutil.copyfile(str(abspath), str(datapath))
        existing_entries = DataFile.select().where(
            (
                (DataFile.abspath == abspath) &
                (DataFile.sha256 == sha256) &
                (DataFile.mtime == stat.st_mtime) &
                (DataFile.size == stat.st_size)
            )
        )
        if existing_entries.count() == 0:
            DataFile.create(abspath=abspath, sha256=sha256, mtime=stat.st_mtime, size=stat.st_size)
def store_file ( self , path : str ) : stat = os . stat ( path ) abspath = Path ( path ) . resolve ( ) sha256 = calculate_file_sha256 ( path ) datapath = self . hash_to_file ( sha256 ) datapath . parent . mkdir ( parents = True , exist_ok = True ) if not datapath . exists ( ) : shutil . copyfile ( str ( abspath ) , str ( datapath ) ) existing_entries = DataFile . select ( ) . where ( ( ( DataFile . abspath == abspath ) & ( DataFile . sha256 == sha256 ) & ( DataFile . mtime == stat . st_mtime ) & ( DataFile . size == stat . st_size ) ) ) if existing_entries . count ( ) == 0 : DataFile . create ( abspath = abspath , sha256 = sha256 , mtime = stat . st_mtime , size = stat . st_size )
Store a file in the local backend.
Store a file in the local backend .
"""
        Store a file in the local backend.

        :ivar path: The path to the file to store
        :return:
        """ # see if we stored this file already # copy over the the cache, # TODO: option to hardlink # Store in the metadata DB if doesn't exist already
None
self
path
str
ivar
The path to the file to store
The path to the file to store