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

MAINT: fix merge errors

parent 03ceca3b
Branches
No related tags found
1 merge request!12DRAFT: ENH: file system: core
Pipeline #47489 failed
......@@ -434,74 +434,6 @@ BEGIN
END //
DROP PROCEDURE IF EXISTS setFileProperties //
/**
* Insert/Update file properties.
*
* If ENTITY_VERSIONING is enabled the old file properties are moved to
* `archive_files`.
*
* 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 setFileProperties (
in FileID INT UNSIGNED,
in FilePath VARCHAR(5000),
in FileSize BIGINT UNSIGNED,
in FileHash VARCHAR(255),
in FileChecked BIGINT,
in FileMimeType VARBINARY(255),
in FileStorageId VARBINARY(255),
in FileKey VARBINARY(40000),
in FileParentID INT UNSIGNED,
in FileHashAlgo VARCHAR(255)
)
BEGIN
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
IF is_feature_config("ENTITY_VERSIONING", "ENABLED") THEN
SELECT max(e._iversion) INTO IVersion
FROM entity_version AS e
WHERE e.entity_id = FileID;
INSERT INTO archive_files (file_id, path, size, hash,
checked_timestamp, mimetype, file_storage_id, file_key,
_iversion, hash_algorithm)
SELECT file_id, path, size, hash, checked_timestamp, mimetype,
file_storage_id, file_key, IVersion AS _iversion, hash_algorithm
FROM files
WHERE file_id = FileID;
END IF;
DELETE FROM files WHERE file_id = FileID;
IF FilePath IS NOT NULL THEN
INSERT INTO files (file_id, path, size, hash, checked_timestamp,
mimetype, file_storage_id, file_key, hash_algorithm)
VALUES (FileID, FilePath, FileSize, unhex(FileHash), FileChecked,
FileMimeType, FileStorageId, FileKey, FileHashAlgo);
END IF;
END //
DROP PROCEDURE IF EXISTS retrieveQueryTemplateDef //
/**
......
......@@ -61,7 +61,9 @@ CREATE PROCEDURE db_5_0.insertFSODescriptor(
IN FileStorageId VARCHAR(255),
IN FileKey VARCHAR(16000))
insertFSODescriptorBody: BEGIN
DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
INSERT INTO files (
file_id,
hash,
......@@ -73,7 +75,7 @@ insertFSODescriptorBody: BEGIN
file_storage_id,
file_key
/*, parent_directory*/
) VALUES (EntityID, unhex(FileHash), FileHashAlgo, FileCheckedTimestamp, FileSize, FilePath, FileMimeType, FileStorageId, FileKey);
) VALUES (InternalEntityID, unhex(FileHash), FileHashAlgo, FileCheckedTimestamp, FileSize, FilePath, FileMimeType, FileStorageId, FileKey);
END;
//
......
......@@ -49,7 +49,7 @@ retrieveFSODescriptorByPathBody: BEGIN
SELECT hash_algorithm AS FileHashAlgo,
byPath as Param,
file_id AS FileId,
(SELECT id FROM entity_ids WHERE internal_id = file_id) AS FileId,
path AS FilePath,
size AS FileSize,
hex(hash) AS FileHash,
......
......@@ -21,43 +21,59 @@
DROP PROCEDURE IF EXISTS setFileProperties;
DELIMITER //
/**
* Update file properties.
* Insert/Update file properties.
*
* If ENTITY_VERSIONING is enabled the old file properties are moved to
* `archive_files`.
*
* Parameters
* ----------
* EntityID : VARCHAR(255)
* The file's id.
* FilePath : TEXT
* Path of the file in the internal file system. If NULL, an existing file
* entity is simply deleted.
* FileSize : BIGINT UNSIGNED
* Size of the file in bytes.
* FileHash : VARCHAR(255)
* A Sha512 Hash of the file.
* 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 setFileProperties (
in EntityID VARCHAR(255),
in FilePath TEXT,
in FileID INT UNSIGNED,
in FilePath VARCHAR(5000),
in FileSize BIGINT UNSIGNED,
in FileHash VARCHAR(255)
in FileHash VARCHAR(255),
in FileChecked BIGINT,
in FileMimeType VARBINARY(255),
in FileStorageId VARBINARY(255),
in FileKey VARBINARY(40000),
in FileParentID INT UNSIGNED,
in FileHashAlgo VARCHAR(255)
)
BEGIN
DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = FileID;
IF is_feature_config("ENTITY_VERSIONING", "ENABLED") THEN
SELECT max(e._iversion) INTO IVersion
FROM entity_version AS e
WHERE e.entity_id = InternalEntityID;
INSERT INTO archive_files (file_id, path, size, hash,
_iversion)
SELECT file_id, path, size, hash, IVersion AS _iversion
checked_timestamp, mimetype, file_storage_id, file_key,
_iversion, hash_algorithm)
SELECT file_id, path, size, hash, checked_timestamp, mimetype,
file_storage_id, file_key, IVersion AS _iversion, hash_algorithm
FROM files
WHERE file_id = InternalEntityID;
END IF;
......@@ -65,8 +81,10 @@ BEGIN
DELETE FROM files WHERE file_id = InternalEntityID;
IF FilePath IS NOT NULL THEN
INSERT INTO files (file_id, path, size, hash)
VALUES (InternalEntityID, FilePath, FileSize, unhex(FileHash));
INSERT INTO files (file_id, path, size, hash, checked_timestamp,
mimetype, file_storage_id, file_key, hash_algorithm)
VALUES (InternalEntityID, FilePath, FileSize, unhex(FileHash), FileChecked,
FileMimeType, FileStorageId, FileKey, FileHashAlgo);
END IF;
END //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment