From 6035662c8cfc75156a14cf2b8a85a73f7905a954 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 13 Apr 2012 16:42:51 +0200 Subject: replace isdir with mode (in database and in code) --- schema.sql | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'schema.sql') diff --git a/schema.sql b/schema.sql index d48c890..9affe44 100644 --- a/schema.sql +++ b/schema.sql @@ -3,7 +3,6 @@ CREATE TABLE dir ( parent_id INTEGER REFERENCES dir( id ), name TEXT, path TEXT, - isdir BOOL, UNIQUE( name, parent_id ), UNIQUE( path ), mode INTEGER NOT NULL DEFAULT 0, @@ -28,17 +27,23 @@ CREATE INDEX data_id_idx ON data( id ); -- directory listings CREATE INDEX dir_parent_id_idx ON dir( parent_id ); +-- 16384 == S_IFDIR (S_IFDIR) +-- TODO: should be created by the program after checking the OS +-- it is running on (for full POSIX compatibility) + -- make sure file entries always get a data -- section in the separate table CREATE OR REPLACE RULE "dir_insert" AS ON - INSERT TO dir WHERE NEW.isdir = false + INSERT TO dir WHERE NEW.mode & 16384 = 0 DO ALSO INSERT INTO data( id ) VALUES ( currval( 'dir_id_seq' ) ); -- garbage collect deleted file entries CREATE OR REPLACE RULE "dir_remove" AS ON - DELETE TO dir WHERE OLD.isdir = false + DELETE TO dir WHERE OLD.mode & 16384 = 0 DO ALSO DELETE FROM data WHERE id=OLD.id; -- self-referencing anchor for root directory -INSERT INTO dir values( 0, 0, '/', '/', true ); +-- 16895 = S_IFDIR and 0777 permissions +-- TODO: should be done from outside, see note above +INSERT INTO dir values( 0, 0, '/', '/', 16895 ); -- cgit v1.2.3-54-g00ecf