I always had access denied. Tracked it down to having drupal_fid to 0 on all my records in filedepot_fileversions.
My files are uploded via native file uploder and are hanlded by the function filedepot_native_submit. I've read that function and found one major bug (not populating the drupal_fid on the filedepot_fileversions record) and one less critical bug, which is that function is using a query to find the last inserted record intead of using native methods for doing that which may leads to errors if more than one people is using the cms :-)
So here's the patch for theses two bugs (I tried to made a nice git patch but I'm lost on your branches):
--- filedepot.module.orig 2012-03-30 15:43:59.000000000 +0200
+++ filedepot.module 2012-03-30 15:31:04.000000000 +0200
@@ -745,37 +745,33 @@
$ext = end(explode(".", $file->filename));
// Create filedepot record for file and set status of file to 1 - online
- $sql = "INSERT INTO {filedepot_files} (cid,fname,title,description,version,drupal_fid,size,mimetype,exte
nsion,submitter,status,date) "
- . "VALUES (:cid,:fname,:title,:desc,1,:fid,:size,:mime,:ext,:uid,1,:time)";
- db_query($sql,
- array(
- ':cid' => $node->folder,
- ':fname' => $file->filename,
- ':title' => $file->filename,
- ':desc' => 'TODO',
- ':fid' => $file->fid,
- ':size' => $file->filesize,
- ':mime' => $file->filemime,
- ':ext' => $ext,
- ':uid' => $user->uid,
- ':time' => time(),
+ $query = db_insert('filedepot_files');
+ $query->fields(array('cid', 'fname', 'title', 'description', 'version', 'drupal_fid', 'size', 'mimetype', 'extension', 'submitter', 'status', 'date'));
+ $query->values(array(
+ 'cid' => $node->folder,
+ 'fname' => $file->filename,
+ 'title' => $file->filename,
+ 'description' => 'TODO',
+ 'version' => 1,
+ 'drupal_fid' => $file->fid,
+ 'size' => $file->filesize,
+ 'mimetype' => $file->filemime,
+ 'extension' => $ext,
+ 'submitter' => $user->uid,
+ 'status' => 1,
+ 'date' => time(),
));
+ $newfid = $query->execute();
- // Get fileid for the new file record
- $args = array(
- ':cid' => $node->folder,
- ':uid' => $user->uid,
- );
- $newfid = db_query_range("SELECT fid FROM {filedepot_files} WHERE cid=:cid AND submitter=:uid ORDER BY fid DESC", 0, 1, $args)->fetchField();
-
- db_query("INSERT INTO {filedepot_fileversions} (fid,fname,version,notes,size,date,uid,status)
- VALUES (:fid,:fname,'1','',:size,:time,:uid,1)",
+ db_query("INSERT INTO {filedepot_fileversions} (fid,fname,version,notes,size,date,uid,status,drupal_fid)
+ VALUES (:fid,:fname,'1','',:size,:time,:uid,1,:drupal_fid)",
array(
':fid' => $newfid,
':fname' => $file->filename,
':size' => $file->filesize,
':time' => time(),
':uid' => $user->uid,
+ ':drupal_fid' => $file->fid,
));
// Update related folders last_modified_date
@@ -1340,14 +1336,11 @@
else {
$query = db_select('filedepot_files', 'a');
$query->join('filedepot_fileversions', 'b', 'b.fid = a.fid');
- //$query->fields('a', array('cid', 'title','drupal_fid'));
- //$query->fields('b', array('fname'));
$query->fields('a', array('cid', 'title'));
$query->fields('b', array('fname','drupal_fid'));
$query->condition('a.fid', $fid, '=');
$query->condition('b.version', $version, '=');
list($cid, $filetitle, $fname, $dfid) = array_values($query->execute()->fetchAssoc());
- //list($cid, $fileti6tle, $dfid, $fname) = array_values($query->execute()->fetchAssoc());
}
$file = file_load($dfid);
Comments
Comment #1
simon georges commentedProper patch attached. All credit goes to regilero.
Comment #2
hilldw commentedI also experienced the same issue and after loading the patch everything is working correctly. Thanks!
Comment #3
simon georges commentedThanks for your feedback!
Comment #4
blainelang commentedThanks guys, I will review and get committed to DEV shortly and post back here.
Comment #5
blainelang commentedPatch committed to the 7.x-1.x dev branch
Comment #6
blainelang commentedComment #8
tiki16 commentedHi, which file am I patching? Tried both .inc But patch couldn't be applied.
Comment #9
blainelang commentedDownload the latest dev branch, it's already patched.
Comment #10
tiki16 commentedI've gone through the read me tried all the different setups to know avail. I can't upload once a folder is created and I get Access Denied when I try to download:
mysite.com/filedepot_download/602/3
In the sites/all/libraries/filedepot/yui_uploader do I have to specify this path in one of the files?
filedepot 6.x-1.3
thanks
Comment #11
blainelang commented@tiki16: This is a 7.x version issue - are you asking about the 6.x branch? If so, please create a new issue.