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