Skip to content
Snippets Groups Projects

Mi rna cache problem

Merged Piotr Gawron requested to merge mi-rna-cache-problem into master
4 files
+ 40
9
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.model.cache.BigFileEntry;
import lcsb.mapviewer.model.user.ConfigurationElementType;
@@ -227,8 +226,9 @@ public class BigFileCache {
* @return new {@link BigFileEntry} for given url
* @throws URISyntaxException
* thrown when url is invalid
* @throws IOException
*/
private BigFileEntry createEntryForBigFile(String url) throws URISyntaxException {
private BigFileEntry createEntryForBigFile(String url) throws URISyntaxException, IOException {
String localPath = configurationDao.getValueByType(ConfigurationElementType.BIG_FILE_STORAGE_DIR);
BigFileEntry entry = new BigFileEntry();
entry.setDownloadDate(Calendar.getInstance());
@@ -237,7 +237,12 @@ public class BigFileCache {
bigFileEntryDao.add(entry);
localPath = entry.getLocalPath() + "/" + entry.getId() + "/";
new File(Configuration.getWebAppDir() + localPath).mkdirs();
File dirFile = new File(Configuration.getWebAppDir() + localPath);
if (!dirFile.mkdirs()) {
throw new IOException("Cannot create directory: " + dirFile.getAbsolutePath());
}
localPath += getFileName(url);
entry.setLocalPath(localPath);
@@ -461,6 +466,9 @@ public class BigFileCache {
output.close();
return null;
} catch (Exception e) {
logger.error(e, e);
throw e;
} finally {
bigFileEntryDao.commit();
// close the transaction for this thread
@@ -838,7 +846,6 @@ public class BigFileCache {
File f = new File(Configuration.getWebAppDir() + entry.getLocalPath());
if (!f.exists()) {
logger.warn("File is supposed to be cached but it's not there... " + sourceUrl);
bigFileEntryDao.delete(entry);
return false;
}
}
Loading