Login | Register
My pages Projects Community openCollabNet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Catacomb] Bug(s) in the catacomb software



I have discovered some bugs in the catacomb software:

The first one is that collection names are not processed correctly if the first letters are identical. If you have a collection named foo and one named foo1 the listing of foo shows the members of foo AND of foo1. The same thing happens if you copy foo.

Here is an example:

dav:/repos/>
dav:/repos/> mkcol foo
Creating `foo': succeeded.
dav:/repos/> mkcol foo/bar
Creating `foo/bar': succeeded.
dav:/repos/> mkcol foo1
Creating `foo1': succeeded.
dav:/repos/> mkcol foo1/bar1
Creating `foo1/ba1': succeeded.
dav:/repos/> ls foo
Listing collection `/repos/foo/': succeeded.
Coll:   bar                                    0 Jun  2 23:25
Coll:   bar1                                    0 Jun  2 23:25
dav:/repos/> cp foo foo3
Copying `/repos/foo' to `/repos/foo3':  succeeded.
dav:/repos/> ls foo3
Listing collection `/repos/foo3/': succeeded.
Coll:   bar                                    0 Jun  2 23:25
Coll:   bar1                                    0 Jun  2 23:25
dav:/repos/>


I tracked the bug down to the SELECT commands in file “dbms.c”
In function dbms_copy_resource the bug is in the line:
"WHERE URI=? or URI like ? '%'");
in the function dbms_get_collection_resource it is this line
From dasl_resource Where URI like ? '%'

I replaced '%' by '/%'. In the other functions like the remove function it is done correcty. For me this solution worked well, but I am not sure if the change has any side effects.

Another problem is that the URIs  are stored with upper and lower case letters but the comparison is done case insensitive. If you upload a file foo and then a file Foo, foo is overwritten by Foo but the name stays foo.

Exapmle:   

# echo foo > foo
# echo Foo > Foo
# cadaver http://127.0.0.1/repos
dav:/repos/> put foo
Uploading foo to `/repos/foo':
Progress: [=============================>] 100.0% of 302 bytes succeeded.
dav:/repos/> ls
Listing collection `/repos/': succeeded.
foo                                    4  Jun  3 00:36
dav:/repos/> cat foo
Displaying `/repos/foo':
foo
dav:/repos/> put Foo
Uploading Foo to `/repos/Foo':
Progress: [=============================>] 100.0% of 4 bytes succeeded.
dav:/repos/> ls
Listing collection `/repos/': succeeded.
foo                                    4  Jun  3 00:36
dav:/repos/> cat foo
Displaying `/repos/foo':
Foo
dav:/repos/>

I solved the problem by changing the type of URI in every table where it is used from text to blob. Doing this the comparison is done case insensitive.

I hope this will help
Detlev Penza

P.S.

I like the stream_dbms branch in the CVS. A year ago I tried to store large files in a database using PHP. The memory usage of PHP exploded and MySql 3 was not able to accept more than 16MB. This limitation is gone with version 4 but I have learned the lesson. Keeping large files and the database separate is the best solution. You can make a full backup of the (relatively small) database and an incremental backup of the data.

I would prefer a more flexible naming scheme building directory names. Using the Ids might be useful in some cases but I changed it to store the files in directory names build from the URI. People using ReiserFS might prefer to store them in a flat files system because this might be faster than your approach.

I would just pass more parameters to the function that creates the filenames so that everyone can do there what he likes best.