CarGuo/GSYVideoPlayer · error · ProxyCacheException

Error append cache: cache file %s is completed!

Error message

Error append cache: cache file %s is completed!

What it means

FileCache.append seeks to end and writes; an IOException during seek/write is formatted as 'Error writing N bytes to <file> from buffer with size M'. Almost always the disk is full or the fd is invalid - the proxy cannot persist downloaded bytes and aborts caching.

Source

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

        }
    }

    @Override
    public synchronized int read(byte[] buffer, long offset, int length) throws ProxyCacheException {
        try {
            dataFile.seek(offset);
            return dataFile.read(buffer, 0, length);
        } catch (IOException e) {
            String format = "Error reading %d bytes with offset %d from file[%d bytes] to buffer[%d bytes]";
            throw new ProxyCacheException(String.format(format, length, offset, available(), buffer.length), e);
        }
    }

    @Override
    public synchronized void append(byte[] data, int length) throws ProxyCacheException {
        try {
            if (isCompleted()) {
                throw new ProxyCacheException("Error append cache: cache file " + file + " is completed!");
            }
            dataFile.seek(available());
            dataFile.write(data, 0, length);
        } catch (IOException e) {
            String format = "Error writing %d bytes to %s from buffer with size %d";
            throw new ProxyCacheException(String.format(format, length, dataFile, data.length), e);
        }
    }

    @Override
    public synchronized void close() throws ProxyCacheException {
        try {
            dataFile.close();
            diskUsage.touch(file);
        } catch (IOException e) {
            throw new ProxyCacheException("Error closing file " + file, e);
        }
    }

View on GitHub (pinned to e5d74d3aa9)

Solutions

  1. Set a sensible maxCacheSize and register cache eviction so the proxy trims before the disk fills
  2. Check StatFs usable space before starting playback on low-storage profiles and prompt the user
  3. Use app-internal cache dir (auto-managed by Android) instead of arbitrary paths
  4. On the error, clear the proxy cache folder and retry playback without caching

Example fix

// before
new Builder(ctx).maxCacheSize(1024L * 1024 * 1024).build(); // 1GB on a full phone

// after - size to free space, evict aggressively
long free = new StatFs(ctx.getCacheDir().getAbsolutePath()).getAvailableBytes();
long cap = Math.min(512L * 1024 * 1024, free / 4);
new Builder(ctx).maxCacheSize(cap).build();
Defensive patterns

Strategy: validation

Validate before calling

StatFs stat = new StatFs(cacheDir.getAbsolutePath());
if (stat.getAvailableBytes() < 50L * 1024 * 1024) {
    trimCacheOrPromptUser(); // or disable caching this session
}

Try / catch

catch (ProxyCacheException e) {
    if (String.valueOf(e.getMessage()).contains("Error writing")) {
        // disk full: clear cache and continue without caching
        clearProxyCache(cacheDir); playDirect(url);
    } else throw e;
}

Prevention

When it happens

Trigger: Device storage fills while the proxy streams a video into the .download temp file; or the cache directory's volume is unmounted / file deleted mid-write (fd invalid).

Common situations: Low-storage budget devices (the classic '16GB with 200MB free' user); cache size cap misconfigured larger than free disk; user clearing storage while streaming; cache dir on adopted/removable storage that flakes.

Related errors


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