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

WIP: filestorage refactoring

parent 6ab7d483
Branches
Tags
1 merge request!12DRAFT: ENH: file system: core
Pipeline #30970 failed
......@@ -41,7 +41,7 @@ ALTER TABLE archive_files DROP COLUMN hash;
-- Add new fields to files table...
ALTER TABLE files ADD COLUMN IF NOT EXISTS (
hash_algorithm VARBINARY(255) NULL DEFAULT "SHA-512",
parent_directory INT UNSIGNED DEFAULT NULL,
-- parent_directory INT UNSIGNED DEFAULT NULL,
mimetype VARBINARY(255) DEFAULT NULL,
file_storage_id VARBINARY(255) NOT NULL DEFAULT "DEFAULT",
file_key VARBINARY(16000) DEFAULT NULL
......@@ -51,7 +51,7 @@ ALTER TABLE files ADD COLUMN IF NOT EXISTS (
ALTER TABLE archive_files ADD COLUMN IF NOT EXISTS (
checked_timestamp BIGINT NOT NULL DEFAULT 0,
hash_algorithm VARBINARY(255) NULL DEFAULT "SHA-512",
parent_directory INT UNSIGNED DEFAULT NULL,
-- parent_directory INT UNSIGNED DEFAULT NULL,
mimetype VARBINARY(255) DEFAULT NULL,
file_storage_id VARBINARY(255) NOT NULL DEFAULT "DEFAULT",
file_key VARBINARY(16000) DEFAULT NULL
......@@ -60,15 +60,15 @@ ALTER TABLE archive_files ADD COLUMN IF NOT EXISTS (
-- no two files at the same path are allowed.
ALTER TABLE files ADD UNIQUE (`path`);
-- directories cannot be deleted without deleting all the content first.
ALTER TABLE files ADD FOREIGN KEY (parent_directory) REFERENCES entities (id);
ALTER TABLE archive_files ADD FOREIGN KEY (parent_directory) REFERENCES entities (id) ON DELETE CASCADE;
-- ALTER TABLE files ADD FOREIGN KEY (parent_directory) REFERENCES entities (id);
-- ALTER TABLE archive_files ADD FOREIGN KEY (parent_directory) REFERENCES entities (id) ON DELETE CASCADE;
ALTER TABLE entities MODIFY COLUMN `role` enum('RECORDTYPE','RECORD','FILE','DOMAIN','PROPERTY','DATATYPE','ROLE','QUERYTEMPLATE', 'DIRECTORY') COLLATE utf8_unicode_ci NOT NULL;
-- ALTER TABLE entities MODIFY COLUMN `role` enum('RECORDTYPE','RECORD','FILE','DOMAIN','PROPERTY','DATATYPE','ROLE','QUERYTEMPLATE', 'DIRECTORY') COLLATE utf8_unicode_ci NOT NULL;
-- Add a new special role "DIRECTORY"
INSERT IGNORE INTO entities (id, description, role, acl) VALUES (9, "The directory role.", "ROLE", 0);
INSERT IGNORE INTO name_data (domain_id, entity_id, property_id, value, status, pidx) VALUES (0, 9, 20, "DIRECTORY", "FIX", 0);
-- INSERT IGNORE INTO entities (id, description, role, acl) VALUES (9, "The directory role.", "ROLE", 0);
-- INSERT IGNORE INTO name_data (domain_id, entity_id, property_id, value, status, pidx) VALUES (0, 9, 20, "DIRECTORY", "FIX", 0);
-- In the default file storage back-end the key is just the path.
UPDATE files SET file_key=path;
......@@ -79,8 +79,8 @@ ALTER TABLE files MODIFY COLUMN file_key VARBINARY(16000) NOT NULL;
ALTER TABLE archive_files MODIFY COLUMN file_key VARBINARY(16000) NOT NULL;
-- Size may be NULL for directories
ALTER TABLE files MODIFY COLUMN size BIGINT UNSIGNED NULL DEFAULT NULL;
ALTER TABLE archive_files MODIFY COLUMN size BIGINT UNSIGNED NULL DEFAULT NULL;
-- ALTER TABLE files MODIFY COLUMN size BIGINT UNSIGNED NULL DEFAULT NULL;
-- ALTER TABLE archive_files MODIFY COLUMN size BIGINT UNSIGNED NULL DEFAULT NULL;
-- More characters for long names
ALTER TABLE files MODIFY COLUMN path VARCHAR(16000) NOT NULL;
......@@ -88,11 +88,11 @@ ALTER TABLE archive_files MODIFY COLUMN path VARCHAR(16000) NOT NULL;
-- Add a special nameless directory which is used as the root directory of the
-- internal file system.
INSERT IGNORE INTO entities (id, description, role, acl) VALUES (51, "The root directory of the internal files system", "DIRECTORY", 0);
INSERT IGNORE INTO files
(file_id, path, checked_timestamp, mimetype, file_storage_id,
file_key, parent_directory)
VALUES (51, "", 0, "inode/directory", "DEFAULT", "", NULL);
-- INSERT IGNORE INTO entities (id, description, role, acl) VALUES (51, "The root directory of the internal files system", "DIRECTORY", 0);
--INSERT IGNORE INTO files
-- (file_id, path, checked_timestamp, mimetype, file_storage_id,
-- file_key, parent_directory)
-- VALUES (51, "", 0, "inode/directory", "DEFAULT", "", NULL);
DROP PROCEDURE IF EXISTS _create_dirs;
DELIMITER //
......@@ -186,7 +186,7 @@ END //
DELIMITER ;
CALL _create_dirs();
-- CALL _create_dirs();
-- not to be used after this patch has been applied.
-- DROP PROCEDURE _create_dirs;
......@@ -43,7 +43,7 @@ BEGIN
-- detele file properties
DELETE FROM files where file_id=EntityID;
DELETE FROM files where parent_directory=EntityID;
/*DELETE FROM files where parent_directory=EntityID;*/
-- delete datatype stuff
DELETE FROM data_type
......
......@@ -55,7 +55,7 @@ create procedure db_5_0.retrieveEntity(
in Version VARBINARY(255))
retrieveEntityBody: BEGIN
DECLARE FilePath VARCHAR(15920) DEFAULT NULL;
DECLARE FileParentID INT UNSIGNED 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;
......@@ -154,8 +154,8 @@ retrieveEntityBody: BEGIN
END IF;
END IF;
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
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;
......@@ -195,7 +195,7 @@ retrieveEntityBody: BEGIN
FileMimetype as FileMimetype,
FileStorageID as FileStorageID,
FileKey as FileKey,
FileParentID as FileParentID,
/*FileParentID as FileParentID,*/
(SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL,
Version AS Version
FROM entities e WHERE id = EntityID LIMIT 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment