CarGuo/GSYVideoPlayer · error · ProxyCacheException
Error opening %s as disc cache
Error message
Error opening %s as disc cache
What it means
Files.makeDir validates the cache directory: if a path exists but is a regular file (not a directory), it throws IOException('File <path> is not directory!'). This fires during FileCache construction when the configured cache root collides with an existing file of the same name.
Source
Thrown at gsyVideoPlayer-proxy_cache/src/main/java/com/danikula/videocache/file/FileCache.java:105
@Override
public synchronized void complete() throws ProxyCacheException {
if (isCompleted()) {
return;
}
close();
String fileName = file.getName().substring(0, file.getName().length() - TEMP_POSTFIX.length());
File completedFile = new File(file.getParentFile(), fileName);
boolean renamed = file.renameTo(completedFile);
if (!renamed) {
throw new ProxyCacheException("Error renaming file " + file + " to " + completedFile + " for completion!");
}
file = completedFile;
try {
dataFile = new RandomAccessFile(file, "r");
diskUsage.touch(file);
} catch (IOException e) {
throw new ProxyCacheException("Error opening " + file + " as disc cache", e);
}
}
@Override
public synchronized boolean isCompleted() {
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) {View on GitHub (pinned to e5d74d3aa9)
Solutions
- Delete the conflicting file or choose a different directory name for the cache root
- Always construct the cache dir via new File(context.getCacheDir(), "proxy_cache") which cannot collide
- At startup, validate the configured path: if exists && !isDirectory, move/delete it before building the proxy
Example fix
// before File cacheDir = new File(getExternalFilesDir(null), "video.cache"); // 'video.cache' may exist as a file // after File cacheDir = new File(context.getCacheDir(), "video_proxy_cache"); if (cacheDir.exists() && !cacheDir.isDirectory()) cacheDir.delete();
Defensive patterns
Strategy: validation
Validate before calling
File cacheDir = new File(context.getCacheDir(), "proxy");
if (cacheDir.exists() && !cacheDir.isDirectory()) {
cacheDir.delete(); // remove blocking file before building proxy
}
cacheDir.mkdirs(); Type guard
boolean isUsableCacheDir = !cacheDir.exists() || cacheDir.isDirectory();
Try / catch
catch (ProxyCacheException e) {
if (String.valueOf(e.getMessage()).contains("is not directory")) {
blockingPath.delete(); // then rebuild HttpProxyCacheServer
} else throw e;
} Prevention
- Build cache paths from getCacheDir()/getExternalCacheDir() subdirs
- Validate configured cache paths at startup
- Never point the cache dir at a path that previously stored a file
When it happens
Trigger: cacheDirectory passed to HttpProxyCacheServer.Builder points at a path where a file already exists - e.g. the developer pointed the cache dir at a path previously used as a file, or storage-cleaner tools replaced the dir entry, or the dir was configured after a file with that exact name was written.
Common situations: Copy-paste cache path mistakes (using a file path instead of dir); persisted user-configurable cache location that once held a file; restoring app data where directory was restored as file (some backup tools do this).
Related errors
- File %s is not directory!
- Directory %s can't be created
- Error reading source ${errorsCount} times
- Error using file ${file} as disc cache
- Error append cache: cache file %s is completed!
AI-assisted analysis of CarGuo/GSYVideoPlayer@e5d74d3aa9 (2026-08-14).
Data as JSON: /api/errors/408fff741ccab740.
Report an issue: GitHub.