Exemplo n.º 1
0
def delete_orig(userId, bucket, archiveid):
    global archive_initialized, data_volume, use_db

    if not archive_initialized:
        raise Exception("archive not initialized")

    if use_db:
        try:
            with db.session_scope() as dbsession:
                rc = db_archivedocument.delete(userId,
                                               bucket,
                                               archiveid,
                                               session=dbsession)
                if not rc:
                    raise Exception("failed to delete")
        except Exception as err:
            raise err
    else:
        try:
            if os.path.exists(
                    os.path.join(data_volume, bucket, archiveid + ".json")):
                os.remove(
                    os.path.join(data_volume, bucket, archiveid + ".json"))
        except Exception as err:
            raise err

    return (True)
Exemplo n.º 2
0
    def delete(self, userId: str, bucket: str, key: str) -> bool:
        if not self.initialized:
            raise Exception("archive not initialized")

        try:
            with db.session_scope() as dbsession:
                rc = db_archivedocument.delete(userId, bucket, key, session=dbsession)
                if not rc:
                    raise Exception("failed to delete DB record")
                else:
                    return True
        except Exception as err:
            raise err
Exemplo n.º 3
0
def delete(userId, bucket, archiveid):
    global archive_initialized, data_volume, use_db

    if not archive_initialized:
        raise Exception("archive not initialized")

    try:
        with db.session_scope() as dbsession:
            rc = db_archivedocument.delete(userId,
                                           bucket,
                                           archiveid,
                                           session=dbsession)
            if not rc:
                raise Exception("failed to delete DB record")

            if not use_db:
                delete_archive_file(userId, bucket, archiveid)

    except Exception as err:
        raise err

    return (True)