Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheFileMetadataIndex does not delete rows in ExoPlayerCacheFileMetadata table after removing file from cache. Is this normal? #6621

Closed
hans-de-clercq opened this issue Nov 6, 2019 · 1 comment
Assignees
Labels

Comments

@hans-de-clercq
Copy link

Issue description

I'm creating an app to play music with crossfade mixes. To play music in the background, I use a foreground service.

I use ProgressiveDownloader to download the next track in the background before preparing. To prepare the player, I use a ProgressiveMediaSource.Factory with a CacheDataSourceFactory and a SimpleCache.
This seems to work perfectly. When a track is played, the track is removed from the cache with ProgressiveDownloader.remove(). The deletion of the track seems to work, but the database table, named ExoPlayerCacheFileMetadata4f582135912e0071 apparently does not remove the matching row. The deletion of the row in table ExoPlayerCacheIndex4f582135912e0071 gets executed correctly. Is this a normal procedure or a small bug?

I also tried the ExoPlayer demo app and when removing a download, I got the same. 0 rows are altered when executing the query to remove a row from the ExoPlayerCacheFileMetadata table in CacheFileMetadataIndex.java.

Reproduction steps

When I debug my app, I enter this method in CacheFileMetadataIndex.java (via CacheUtil.remove(cache, key) -> SimpleCache.removeSpan(span) -> SimpleCache.removeSpanInternal(span))

public void remove(String name) throws DatabaseIOException {
    Assertions.checkNotNull(tableName);
    try {
      SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
      writableDatabase.delete(tableName, WHERE_NAME_EQUALS, new String[] {name});
    } catch (SQLException e) {
      throw new DatabaseIOException(e);
    }
  }

When I dig deeper in these methode, a SQLStatement is created to remove the matching row in the database, something like DELETE FROM ExoPlayerCacheFileMetadata1e75b6426726c95c WHERE 0 = ? with bindArgs 0="3.0.1573029543652.v3.exo". This row exists in the database. No error is thrown in the next steps of the code executing this SQL statement, but when the SQL statement is executed, 0 is returned as nb rows affected. All the parameters and data seem ok, but the query does not delete the row.

Version of ExoPlayer being used

ExoPlayer version used: 2.10.1

Device(s) and version(s) of Android being used

I tried this on emulators with API 27 and API 29, and on my Samsung J5 device with API 23.

@ojw28
Copy link
Contributor

ojw28 commented Dec 10, 2019

Yes, this is a small bug. WHERE 0 = ? should be WHERE name = ?. We'll get that fixed.

@ojw28 ojw28 assigned ojw28 and unassigned marcbaechinger Dec 10, 2019
ojw28 added a commit that referenced this issue Dec 10, 2019
@ojw28 ojw28 closed this as completed Dec 10, 2019
ojw28 added a commit that referenced this issue Dec 10, 2019
@google google locked and limited conversation to collaborators Feb 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants