Skip to content
Snippets Groups Projects
Commit ca1a6ad4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when removing big file remove all of them

parent 7d0413dd
No related branches found
No related tags found
1 merge request!262some optimizations + fix on pubmed listing
Pipeline #
...@@ -11,6 +11,7 @@ import java.net.URI; ...@@ -11,6 +11,7 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
...@@ -621,20 +622,19 @@ public class BigFileCache { ...@@ -621,20 +622,19 @@ public class BigFileCache {
* thrown when there is a problem with deleting file * thrown when there is a problem with deleting file
*/ */
public void removeFile(String url) throws IOException { public void removeFile(String url) throws IOException {
BigFileEntry entry = bigFileEntryDao.getByUrl(url); List<BigFileEntry> entries = bigFileEntryDao.getAllByUrl(url);
if (entry == null) { for (BigFileEntry entry : entries) {
throw new InvalidArgumentException("Cannot remove file. File wasn't downloaded: " + url); String path = Configuration.getWebAppDir() + entry.getLocalPath();
} File f = new File(path);
String path = Configuration.getWebAppDir() + entry.getLocalPath(); if (!f.exists()) {
File f = new File(path); logger.warn("Missing file: " + path + ". Downloaded from: " + url);
if (!f.exists()) { }
logger.warn("Missing file: " + path + ". Downloaded from: " + url); String dirPath = FilenameUtils.getFullPath(path);
}
String dirPath = FilenameUtils.getFullPath(path);
FileUtils.deleteDirectory(new File(dirPath)); FileUtils.deleteDirectory(new File(dirPath));
bigFileEntryDao.delete(entry); bigFileEntryDao.delete(entry);
}
} }
/** /**
......
...@@ -45,30 +45,38 @@ ...@@ -45,30 +45,38 @@
"litemol": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b" "litemol": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b"
}, },
"dependencies": { "dependencies": {
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
}
}
},
"jquery": { "jquery": {
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==", "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
"dev": true "dev": true
} },
} "litemol": {
}, "version": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b",
"ProtVista": { "dev": true,
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e", "requires": {
"dev": true, "@types/react": "15.6.14",
"requires": { "@types/react-dom": "15.5.7"
"d3": "3.5.17", }
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
} }
} }
}, },
...@@ -2050,14 +2058,6 @@ ...@@ -2050,14 +2058,6 @@
"immediate": "3.0.6" "immediate": "3.0.6"
} }
}, },
"litemol": {
"version": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b",
"dev": true,
"requires": {
"@types/react": "15.6.14",
"@types/react-dom": "15.5.7"
}
},
"lodash": { "lodash": {
"version": "4.17.4", "version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
......
...@@ -14,38 +14,42 @@ import lcsb.mapviewer.persist.dao.BaseDao; ...@@ -14,38 +14,42 @@ import lcsb.mapviewer.persist.dao.BaseDao;
* *
*/ */
public class BigFileEntryDao extends BaseDao<BigFileEntry> { public class BigFileEntryDao extends BaseDao<BigFileEntry> {
/** /**
* Default class logger. * Default class logger.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private Logger logger = Logger.getLogger(BigFileEntryDao.class); private Logger logger = Logger.getLogger(BigFileEntryDao.class);
/** /**
* Default constructor. * Default constructor.
*/ */
public BigFileEntryDao() { public BigFileEntryDao() {
super(BigFileEntry.class, "removed"); super(BigFileEntry.class, "removed");
} }
/** /**
* Return {@link BigFileEntry} identified by remote url. * Return {@link BigFileEntry} identified by remote url.
* *
* @param url * @param url
* url of the file * url of the file
* @return {@link BigFileEntry} identified by remote url * @return {@link BigFileEntry} identified by remote url
*/ */
public BigFileEntry getByUrl(String url) { public BigFileEntry getByUrl(String url) {
List<?> list = getElementsByParameter("url", url); List<?> list = getElementsByParameter("url", url);
if (list.size() == 0) { if (list.size() == 0) {
return null; return null;
} }
return (BigFileEntry) list.get(0); return (BigFileEntry) list.get(0);
} }
@Override public List<BigFileEntry> getAllByUrl(String url) {
public void delete(BigFileEntry entry) { return getElementsByParameter("url", url);
entry.setRemoved(true); }
update(entry);
} @Override
public void delete(BigFileEntry entry) {
entry.setRemoved(true);
update(entry);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment