Video file upload errors with Cloud FIles I'm using the CloudFiles module to host my uploaded files on Rackspace Cloud Files. This is working very well for all of the photos I'm uploading, but it seems to be failing when I upload videos.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
'rcf://videos' for key 'PRIMARY': INSERT INTO {cloud_files} (uri, filemime, filesize) 
VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); 
Array ( [:db_insert_placeholder_0] =&gt; rcf://videos [:db_insert_placeholder_1] =&gt; 
application/directory [:db_insert_placeholder_2] =&gt; 1 ) in drupal_write_record() 
(line 7013 of /var/www/vhosts/mydomain.com/includes/common.inc).


I'm not sure, but it appears that when the process finally gets to the CloudFiles module and the CF module is trying to insert that into the database, the filename appears to only be "rcf://videos" when it should be something more like "rcf://videos/original/my_test_video.mp4" (I'm guessing). 

But perhaps this is the wrong understanding of what I'm seeing. It appears that there is a directory entry in the cloud_files db table, so perhaps the module is trying to insert entries for the intervening directories and it's accidentally trying to insert it twice or something... I don't know. I'm confused.

I'm not a drupal wizard (yet!) so I'm having real problems tracing this error down to its source. I'm assuming the issue is in the Video module since the CloudFiles module is working for image uploads.

Can you help me track down where the filename is set and/or converted?
Found the issue, it was with the Cloud Files module (I'm using a dev version) and I've submitted a fix to the author. 

The Cloud Files code was creating directory entries in the db for all of the intervening directories when mkdir() was called. The mkdir() code in the file stream wrapper was always trying to insert a row into the cloud_files table. My guess is that it was assumed other modules would check for the existence of a directory before creating it, so he didn't want to do a redundant check. However, I think that other code would usually just blindly call mkdir() because if the directory already existed and it failed there wasn't any real downside to it.