diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-04-13 16:42:51 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-04-13 16:42:51 +0200 |
commit | 6035662c8cfc75156a14cf2b8a85a73f7905a954 (patch) | |
tree | 3126b7058a566a3a99b5ef98d8a9efb4e932d93a /schema.sql | |
parent | d3e3ad5b428ed46aff71ee0b0e05902cd6ab9678 (diff) | |
download | pgfuse-6035662c8cfc75156a14cf2b8a85a73f7905a954.tar.gz pgfuse-6035662c8cfc75156a14cf2b8a85a73f7905a954.tar.bz2 |
replace isdir with mode (in database and in code)
Diffstat (limited to 'schema.sql')
-rw-r--r-- | schema.sql | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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 ); |