Skip to content
Snippets Groups Projects
Verified Commit 40fb1793 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: file system

parent 242ffe02
No related branches found
No related tags found
1 merge request!12DRAFT: ENH: file system: core
Pipeline #18866 failed
......@@ -450,7 +450,8 @@ CREATE PROCEDURE setFileProperties (
in FileMimetype VARBINARY(255),
in FileStorageId VARBINARY(255),
in FileKey VARBINARY(40000),
in FileParentID INT UNSIGNED
in FileParentID INT UNSIGNED,
in FileHashAlgo VARCHAR(255)
)
BEGIN
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
......@@ -461,9 +462,9 @@ BEGIN
INSERT INTO archive_files (file_id, path, size, hash,
checked_timestamp, mimetype, file_storage_id, file_key,
_iversion)
_iversion, hash_algorithm)
SELECT file_id, path, size, hash, checked_timestamp, mimetype,
file_storage_id, file_key, IVersion AS _iversion
file_storage_id, file_key, IVersion AS _iversion, hash_algorithm
FROM files
WHERE file_id = FileID;
END IF;
......@@ -472,9 +473,9 @@ BEGIN
IF FilePath IS NOT NULL THEN
INSERT INTO files (file_id, path, size, hash, checked_timestamp,
mimetype, file_storage_id, file_key)
mimetype, file_storage_id, file_key, hash_algorithm)
VALUES (FileID, FilePath, FileSize, unhex(FileHash), FileChecked,
FileMimetype, FileStorageId, FileKey);
FileMimetype, FileStorageId, FileKey, FileHashAlgo);
END IF;
END //
......
/*
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
DROP PROCEDURE IF EXISTS db_5_0.insertFSODescriptor;
delimiter //
/**
* Insert a FSODescriptor
*
* Parameters
* ----------
* FileID
* The entity's id.
* FileHash
* The SHA512 Hash of the file (or NULL for directories).
* FileCheckedTimestamp
* The timestamp when the hash was last checked.
* FileSize
* The byte size (or NULL for directories).
* FilePath
* The path of the object.
* FileMimetype
* The mimetype (use "inode/directory" for directories, use NULL for unknown)
* FileStorageID
* The ID of the back-end file storage where this object is located.
* FileKey
* The file storage key of this object.
* FileParentID
* The entity id of the parent directory (or NULL).
*/
CREATE PROCEDURE db_5_0.insertFSODescriptor(
in FileID INT UNSIGNED,
in FileHash VARCHAR(255),
in FileCheckedTimestamp BIGINT,
in FileSize BIGINT UNSIGNED,
in FilePath VARCHAR(5000),
in FileMimetype VARBINARY(255),
in FileStorageID VARBINARY(255),
in FileKey VARBINARY(40000),
in FileParentID INT UNSIGNED
)
BEGIN
INSERT INTO files
(file_id, parent_directory, hash, checked_timestamp, size, path,
mimetype, file_storage_id, file_key)
VALUES (FileID, FileParentID, unhex(FileHash), FileCheckedTimestamp,
FileSize, FilePath, FileMimetype, FileStorageID, FileKey);
END;
//
delimiter ;
......@@ -46,21 +46,23 @@ drop procedure if exists db_5_0.retrieveEntity //
* ResultSet
* ---------
* Tuple of (DatatypeID, Collection, EntityID, EntityName, EntityDesc,
* EntityRole, FileSize, FilePath, FileHash, FileHashChecked,
* FileMimetype, FileStorageID, FileKey, FileParentID, ACL, Version)
* EntityRole, FileSize, FilePath, FileHash, FileHashAlgo,
* FileHashChecked, FileMimetype, FileStorageID, FileKey,
* FileParentID, ACL, Version)
*/
create procedure db_5_0.retrieveEntity(
in EntityID INT UNSIGNED,
in Version VARBINARY(255))
retrieveEntityBody: BEGIN
DECLARE FilePath VARCHAR(5000) DEFAULT NULL;
DECLARE FilePath VARCHAR(15920) DEFAULT NULL;
DECLARE FileParentID INT UNSIGNED DEFAULT NULL;
DECLARE FileSize BIGINT UNSIGNED DEFAULT NULL;
DECLARE FileHash VARCHAR(255) DEFAULT NULL;
DECLARE FileHashAlgo VARCHAR(255) DEFAULT NULL;
DECLARE FileHashChecked BIGINT DEFAULT NULL;
DECLARE FileMimetype VARBINARY(255) DEFAULT NULL;
DECLARE FileStorageID VARBINARY(255) DEFAULT NULL;
DECLARE FileKey VARBINARY(40000) DEFAULT NULL;
DECLARE FileKey VARBINARY(15920) DEFAULT NULL;
DECLARE DatatypeID INT UNSIGNED DEFAULT NULL;
DECLARE CollectionName VARCHAR(255) DEFAULT NULL;
DECLARE IsHead BOOLEAN DEFAULT TRUE;
......@@ -87,8 +89,8 @@ retrieveEntityBody: BEGIN
LEAVE retrieveEntityBody;
END IF;
SELECT path, size, hex(hash), checked_timestamp, mimetype, file_storage_id, file_key
INTO FilePath, FileSize, FileHash, FileHashChecked, FileMimetype, FileStorageID, FileKey
SELECT path, size, hex(hash), hash_algorithm, checked_timestamp, mimetype, file_storage_id, file_key
INTO FilePath, FileSize, FileHash, FileHashAlgo, FileHashChecked, FileMimetype, FileStorageID, FileKey
FROM archive_files
WHERE file_id = EntityID
AND _iversion = IVersion
......@@ -152,8 +154,8 @@ retrieveEntityBody: BEGIN
END IF;
END IF;
SELECT path, parent_directory, size, hex(hash), checked_timestamp, mimetype, file_storage_id, file_key
INTO FilePath, FileParentID, FileSize, FileHash, FileHashChecked, FileMimetype, FileStorageID, FileKey
SELECT path, parent_directory, size, hex(hash), hash_algorithm, checked_timestamp, mimetype, file_storage_id, file_key
INTO FilePath, FileParentID, FileSize, FileHash, FileHashAlgo, FileHashChecked, FileMimetype, FileStorageID, FileKey
FROM files
WHERE file_id = EntityID
LIMIT 1;
......@@ -188,6 +190,7 @@ retrieveEntityBody: BEGIN
FileSize AS FileSize,
FilePath AS FilePath,
FileHash AS FileHash,
FileHashAlgo AS FileHashAlgo,
FileHashChecked AS FileHashChecked,
FileMimetype as FileMimetype,
FileStorageID as FileStorageID,
......
......@@ -23,25 +23,6 @@
DELIMITER //
DROP PROCEDURE IF EXISTS db_5_0.retrieveSubEntity //
/**
CREATE PROCEDURE db_5_0.retrieveSubEntity(in EntityID INT UNSIGNED, in DomainID INT UNSIGNED)
BEGIN
DECLARE FilePath VARCHAR(255) DEFAULT NULL;
DECLARE FileSize VARCHAR(255) DEFAULT NULL;
DECLARE FileHash VARCHAR(255) DEFAULT NULL;
Select path, size, hex(hash) into FilePath, FileSize, FileHash from files where file_id = EntityID LIMIT 1;
Select DomainID as DomainID,
EntityID as EntityID,
e.name as EntityName,
e.description as EntityDesc,
e.role as EntityRole,
FileSize as FileSize,
FilePath as FilePath,
FileHash as FileHash
from entities e where id = EntityID LIMIT 1;
END;
//
**/
DELIMITER ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment