CarGuo/GSYVideoPlayer · error · ProxyCacheException

Error renaming file to for completion!

Error message

Error renaming file %s to %s for completion!

What it means

After a successful rename, FileCache.complete reopens the finished file read-only (new RandomAccessFile(file, "r')) and touches DiskUsage. IOException here becomes ProxyCacheException('Error opening <file> as disc cache'). The file exists and is renamed, but can no longer be opened for reading - permissions changed, file deleted instantly by a cleaner, or fs errors.

Solutions

  1. Enforce one proxy instance per cache directory (singleton pattern)
  2. On the error, purge the url's cache entry and let the next playback re-download
  3. Use internal, app-private cache storage immune to external cleaners
  4. If persistent, check device storage health / remount loops

Example fix

// before - fatal
catch (ProxyCacheException e) { throw e; }

// after - purge entry and degrade to no-cache playback
catch (ProxyCacheException e) {
    Log.w(TAG, "reopening completed cache failed, purging entry", e);
    new File(cacheDir, md5(url)).delete();
    playDirectWithoutCache(url);
}
Defensive patterns

Strategy: fallback

Validate before calling

File f = new File(cacheDir, md5(url));
if (!f.exists() || !f.canRead()) { /* purge entry, degrade to no-cache */ f.delete(); }

Try / catch

catch (ProxyCacheException e) {
    if (String.valueOf(e.getMessage()).contains("Error opening") && e.getMessage().contains("as disc cache")) {
        purgeEntry(url); playDirect(url);
    } else throw e;
}

Prevention

When it happens

Trigger: Immediately after rename, something deletes or locks the completed file (eviction thread from another proxy instance, cleaner app), or the directory's permissions prevent reopen. Rare; requires a race or external interference in the microseconds between rename and reopen.

Common situations: Two cache instances trimming the same folder concurrently; storage cleaner racing the proxy; almost never seen in single-instance, internal-storage setups.

Related errors


AI-assisted analysis of CarGuo/GSYVideoPlayer@e5d74d3aa9 (2026-08-14). Data as JSON: /api/errors/78a8581ac32dc557. Report an issue: GitHub.

Appendix: source

Thrown at gsyVideoPlayer-proxy_cache/src/main/java/com/danikula/videocache/file/FileCache.java:98

            dataFile.close();
            diskUsage.touch(file);
        } catch (IOException e) {
            throw new ProxyCacheException("Error closing file " + file, e);
        }
    }

    @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.
     *

View on GitHub (pinned to e5d74d3aa9)