This probably does belong in development, because I encountered something simialr last night building a D7 site from scratch. Well, actually, it probably should be in the D7 issues queue.
 
I had added a few images to articles, then realized I hadn't set the correct file path. I changed my filepath setting and went back to those nodes. I removed the current image, then added the picture again (same edit session). Every one resulted in this error. Worse, the error overlays the page with no way to clear it except to go to another page. AFAICT, the image was actually loaded again.
 

Nancy

 

Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.




From: Blaine Lang
 

I am working on an enhancement to the filedepot module for a multifile uploader - drag & drop files to a hotspot on the browser. It was all working nicely but now consistently getting duplicate entry errors in both the node_access and the CCK table

 

The filedepot_folder is a node and the files are attachments - using the filefield CCK widget.

 

Duplicate entry '16-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (16, 'all';, 0, 1, 0, 0)

 

Duplicate entry '16-1' for key 1 query: INSERT INTO content_field_filedepot_file (vid, nid, delta, field_filedepot_file_fid, field_filedepot_file_list, field_filedepot_file_data) VALUES (16, 16, 1, 234, NULL, NULL)

 

I've stripped the module code down to only the following and modules HOOK_nodeapi is just doing a return so no other code in filedepot should be involved.

 

$node = node_load($file->nid, NULL, TRUE);

$field = content_fields('field_filedepot_file', 'filedepot_folder');

$validators = filefield_widget_upload_validators($field);

 

$nodefile = field_file_save_file($file->tmp_name, $validators, $this->tmp_storage_path);

// Need to populate the CCK fields for the filefield field - so node_save will update the CCK field

$node->field_filedepot_file[] = $nodefile;

node_save($node);

 

// Clear CCK data cache so the new value will be loaded for display purposes

cache_clear_all('content:' . $node->nid . ':' . $node->vid, 'cache_content');

 

I was suspecting a race condition as the files I'm uploading are small test files and thought the node_save was not completed before another update was attempted but attempts to remove this potential race condition still cause the same issue.

 

Often the first 2 or 3 files get attached just fine to the folder node and then the next file triggers the SQL error then a few more may save ok and then SQL error but the pattern is not consistent.