Fix if a file is deleted before text extraction is finished

This commit is contained in:
jendib 2016-03-24 00:41:31 +01:00
parent ef16561272
commit 274512a58e
2 changed files with 5 additions and 3 deletions

View File

@ -155,10 +155,12 @@ public class FileDao {
* @param id File ID
* @return File
*/
public File getById(String id) {
public File getActiveById(String id) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Query q = em.createQuery("select f from File f where f.id = :id and f.deleteDate is null");
q.setParameter("id", id);
try {
return em.find(File.class, id);
return (File) q.getSingleResult();
} catch (NoResultException e) {
return null;
}

View File

@ -54,7 +54,7 @@ public class FileCreatedAsyncListener {
@Override
public void run() {
FileDao fileDao = new FileDao();
if (fileDao.getById(file.getId()) == null) {
if (fileDao.getActiveById(file.getId()) == null) {
// The file has been deleted since the text extraction started, ignore the result
return;
}