mirror of
https://github.com/sismics/docs.git
synced 2024-11-26 07:34: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
|
* @param id File ID
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public File getById(String id) {
|
public File getActiveById(String id) {
|
||||||
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
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 {
|
try {
|
||||||
return em.find(File.class, id);
|
return (File) q.getSingleResult();
|
||||||
} catch (NoResultException e) {
|
} catch (NoResultException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class FileCreatedAsyncListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FileDao fileDao = new FileDao();
|
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
|
// The file has been deleted since the text extraction started, ignore the result
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user