Deleting items that failed to import

While undoing a CSV import, we lost connection to the server, causing the undo to freeze up. We were unable to get the undo restarted and reset the plugin to clear our status list. However, the items that weren't un-imported remain in our archive. When we try to delete them, we get this error:

Unable to delete file

exception 'Omeka_Storage_Exception' with message 'Unable to delete file.' in /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Storage/Adapter/Filesystem.php:153
Stack trace:
#0 [internal function]: Omeka_Storage_Adapter_Filesystem->delete('files/769fac075...')
#1 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Storage.php(66): call_user_func_array(Array, Array)
#2 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/models/File.php(232): Omeka_Storage->__call('delete', Array)
#3 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/models/File.php(232): Omeka_Storage->delete('files/769fac075...')
#4 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/models/File.php(238): File->unlinkFile()
#5 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Record.php(622): File->_delete()
#6 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/models/Item.php(253): Omeka_Record->delete()
#7 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/models/Item.php(233): Item->_deleteFiles()
#8 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Record.php(622): Item->_delete()
#9 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/models/Item/BatchEditJob.php(26): Omeka_Record->delete()
#10 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Job/Dispatcher/Adapter/Synchronous.php(26): Item_BatchEditJob->perform()
#11 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Job/Dispatcher/Default.php(91): Omeka_Job_Dispatcher_Adapter_Synchronous->send('{"className":"I...', Array)
#12 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/controllers/ItemsController.php(377): Omeka_Job_Dispatcher_Default->send('Item_BatchEditJ...', Array)
#13 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Zend/Controller/Action.php(513): ItemsController->batchEditSaveAction()
#14 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('batchEditSaveAc...')
#15 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#16 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#17 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#18 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/application/libraries/Omeka/Core.php(166): Zend_Application->run()
#19 /home/mhistadmin/webapps/clehistoryblogs/exhibit-space/admin/index.php(45): Omeka_Core->run()
#20 {main}

Any idea on how we can get these items deleted from our archive?


There's a way to solve this by editing the database directly, but we've had a fair number of people get into strange situations that cause this "undeletable item" problem now.

So, we're going to include a fix for this in a bugfix update for Omeka 1.4 in the near future.

If you'd rather wait until the update, it should resolve your problem.


So do you mean that I can delete the failed import items with a single MySQL command, rather than doing each one manually? How would command know that it was dealing with an item that had not fully imported?

There's no one-shot command people can use in most cases for this.

Some people have had a situation where (for example) their disk was full, and Omeka was saving items with zero-sized files (and the files themselves were missing, of course). A query to delete all the File records with a size column of zero would fix things for them.

In your case, what appears to have happened is that the underlying files are gone, but the File records remain in the database. As part of the changes to the file storage system in Omeka 1.4, we added some better error checking and exception handling.

Unfortunately, the storage system in 1.4 (and 1.4.1) throws an exception when you try to delete a File record and the real file on the filesystem isn't there (or can't be deleted for some other reason).

Enough people get into this situation (by say, manually deleting files, or having processes aborted partway through), that we're changing that deletion behavior to instead log that there was an error deleting the file, but still allow users to go through with deleting the affected File or Item.

Hi all, I'm working with @michaelgrotman on this issue.

Would it be possible to delete these items/files by querying for items with a common attribute?

We've tagged them all with the same value (FailedImport) but I'm not so great with SQL so I don't actually know how such a command would look.

Anyone feel like sharing some code?

Thanks -- Erin

It's definitely possible to do this with SQL, but the 1.4.2 maintenance release of Omeka is due to be released next week, and would allow you to delete these items through the Omeka interface, and take advantage of the existing browse items filters and batch editing.

(Psst... don't tell anybody, but the prospective release version of 1.4.2 is here.)

Omeka 1.4.2 is now released and contains a fix for this issue.