add ability to know what the file is used for file cache (FileCache.getFile())

This commit is contained in:
Alexey Danilov
2015-04-02 13:25:08 +03:00
parent b3782713cc
commit 39c9ab27a3
2 changed files with 11 additions and 2 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.danikula</groupId>
<artifactId>videocache</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<version>1.0.1</version>
<name>VideoCache</name>
<description>cache support for android VideoView</description>

View File

@@ -20,7 +20,7 @@ public class FileCache implements Cache {
public FileCache(File file) throws ProxyCacheException {
try {
Preconditions.checkNotNull(file);
checkNotNull(file);
boolean partialFile = isTempFile(file);
boolean completed = file.exists() && !partialFile;
if (completed) {
@@ -105,6 +105,15 @@ public class FileCache implements Cache {
return !isTempFile(file);
}
/**
* Returns file to be used fo caching. It may as original file passed in constructor as some temp file for not completed cache.
*
* @return file for caching.
*/
public File getFile() {
return file;
}
private boolean isTempFile(File file) {
return file.getName().endsWith(TEMP_POSTFIX);
}