CC-1713 - New storage directory structure

Changed the GUNID to a 32 hex string (MD5 value), there is no more
conversion between hex strings and bigints in the database anymore.

Added added the file extension to the file name.

Stored the complete path to the file in the database.  This means that
linking doesnt need to create any files at all. (It used to create a
symlink to the file you were importing)

The structure and file naming should be fine - there are 4096 possibilities
for the first directory level, and even will a million files this is only
244 files per sub-directory.  The GUID is fine for the file name
This commit is contained in:
paul.baranowski 2010-11-11 16:50:30 -05:00
parent 3879d1c7d4
commit 35dc3fd01f
8 changed files with 215 additions and 78 deletions

View file

@ -9,7 +9,7 @@ DROP TABLE "cc_access" CASCADE;
CREATE TABLE "cc_access"
(
"id" serial NOT NULL,
"gunid" INT8,
"gunid" CHAR(32),
"token" INT8,
"chsum" CHAR(32) default '' NOT NULL,
"ext" VARCHAR(128) default '' NOT NULL,
@ -61,10 +61,11 @@ DROP TABLE "cc_files" CASCADE;
CREATE TABLE "cc_files"
(
"id" serial NOT NULL,
"gunid" INT8 NOT NULL,
"gunid" CHAR(32) NOT NULL,
"name" VARCHAR(255) default '' NOT NULL,
"mime" VARCHAR(255) default '' NOT NULL,
"ftype" VARCHAR(128) default '' NOT NULL,
"filepath" TEXT default '',
"state" VARCHAR(128) default 'empty' NOT NULL,
"currentlyaccessing" INTEGER default 0 NOT NULL,
"editedby" INTEGER,
@ -339,7 +340,7 @@ CREATE TABLE "cc_trans"
"target" VARCHAR(255),
"rtrtok" CHAR(16),
"mdtrtok" CHAR(16),
"gunid" INT8,
"gunid" CHAR(32),
"pdtoken" INT8,
"url" VARCHAR(255),
"localfile" VARCHAR(255),

View file

@ -3,7 +3,7 @@
<database name="campcaster" defaultIdMethod="native">
<table name="cc_access" phpName="CcAccess">
<column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="gunid" phpName="Gunid" type="BIGINT" required="false"/>
<column name="gunid" phpName="Gunid" type="CHAR" size="32" required="false"/>
<column name="token" phpName="Token" type="BIGINT" required="false"/>
<column name="chsum" phpName="Chsum" type="CHAR" size="32" required="true" defaultValue=""/>
<column name="ext" phpName="Ext" type="VARCHAR" size="128" required="true" defaultValue=""/>
@ -33,10 +33,11 @@
</table>
<table name="cc_files" phpName="CcFiles">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="gunid" phpName="Gunid" type="BIGINT" required="true"/>
<column name="gunid" phpName="Gunid" type="char" size="32" required="true"/>
<column name="name" phpName="Name" type="VARCHAR" size="255" required="true" defaultValue=""/>
<column name="mime" phpName="Mime" type="VARCHAR" size="255" required="true" defaultValue=""/>
<column name="ftype" phpName="Ftype" type="VARCHAR" size="128" required="true" defaultValue=""/>
<column name="filepath" phpName="filepath" type="LONGVARCHAR" required="false" defaultValue=""/>
<column name="state" phpName="State" type="VARCHAR" size="128" required="true" defaultValue="empty"/>
<column name="currentlyaccessing" phpName="Currentlyaccessing" type="INTEGER" required="true" defaultValue="0"/>
<column name="editedby" phpName="Editedby" type="INTEGER" required="false"/>
@ -232,7 +233,7 @@
<column name="target" phpName="Target" type="VARCHAR" size="255" required="false" defaultValue="NULL"/>
<column name="rtrtok" phpName="Rtrtok" type="CHAR" size="16" required="false" defaultValue="NULL"/>
<column name="mdtrtok" phpName="Mdtrtok" type="CHAR" size="16" required="false"/>
<column name="gunid" phpName="Gunid" type="BIGINT" required="false"/>
<column name="gunid" phpName="Gunid" type="char" size="32" required="false"/>
<column name="pdtoken" phpName="Pdtoken" type="BIGINT" required="false"/>
<column name="url" phpName="Url" type="VARCHAR" size="255" required="false"/>
<column name="localfile" phpName="Localfile" type="VARCHAR" size="255" required="false"/>