I am have written a very nice photo/video album module that currently implements its own filestore. I would like to use an existing filestore and think the filemanager is the top contender. I start off with a temporary named file that I would like to rename later. But currently, the filemanager API has no way to rename a file that is currently in the filestore.

I would be more than willing to implement this feature myself, but before I do, I wanted to make sure that the maintainer/owner was okay with the idea. And I would appreciate any help in the way of usage models -- I am not sure if renaming fits in with the intended usage model of filemanager.

Comments

vhmauery’s picture

Status: Active » Needs review
StatusFileSize
new6.73 KB

This patch adds rename support. It also fixes some other minor bugs in the filemanager code. Namely, it fixes a bug in filemanager_url that incorrectly handled the absolute/relative case, what looked like a possible race condition in filemanager_add_file and a bug in how it counted the number of files in a directory (it looked an otherwise unused variable $curdir)

To add the rename support, I moved the directory finding code out of filemanager_add_file into its own function and called that both from the add file and rename file functions. And I abstracted the locking mechanism to make it easier to use.

I also added a function called filemanager_get_working_copy which returns the working copy of a file if there is one or copies the active file into the working dir and returns that. This was just a very convenient function.

Please look at the patch and include it if it is good. Acidfree, my photo album module requires these changes.

vhmauery’s picture

StatusFileSize
new6.69 KB

The last patch introduced an error in filemanager_url. Oops. Here is a patch to replace the first one.

ccourtne’s picture

Status: Needs review » Closed (fixed)

I have applied the patch. The patch had one bug where it would not properly update the directory number in the database when renaming a file.