mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
Fix if a file is deleted before text extraction is finished
This commit is contained in:
parent
ef16561272
commit
274512a58e
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user