Managing how to delete the videoConfig when `onError` event is triggered?

I am working on a React Native application where we add downloads functionality. The code was built as a native modules in the Java enviroment. However we found a potential issue related with trying to delete a video when a error event occured (noOptionsAvailable or downlaodFailed) . We manage this by when the event is triggered, we send a payload to update the state of the video downloaded in our DB on our React Native app. On top of this, we delete the video from our database when is failed but also it triggeres the action to bitmovin to do the same internally (offlineContentManager.clearAll()).

The thing is when I try to download the same video avoiding to produce an error, the video doesn’t download, when debugging it seems that bitmovin didn’t clear the videoConfig from the downlaod folder.

So I was wonder how would be the best practice here to remove efficiently any trace from a video when this has been failed.

Here some snippets:

Delete react function:

    public void deleteVideo(String videoManifestUrl) {
        if (videoManifestUrl != null) {
            OfflineContentManager offlineContentManager;
            if (_stateHashMap.containsKey(videoManifestUrl)) {
                offlineContentManager = _stateHashMap.get(videoManifestUrl).getOfflineContentManager();
            } else {
                SourceConfig sourceConfig = new SourceConfig(videoManifestUrl, SourceType.Dash);
                offlineContentManager = OfflineContentManager.getOfflineContentManager(sourceConfig,
                OfflineManagerAction offlineManagerAction = new OfflineManagerAction(offlineContentManager, DELETE);
                _stateHashMap.put(sourceConfig.getUrl(), offlineManagerAction);

And the onError event handler:

    public void onError(SourceConfig sourceConfig, ErrorEvent errorEvent) {
        if (errorEvent instanceof OfflineErrorEvent && _stateHashMap.containsKey(sourceConfig.getUrl())) {
            OfflineManagerAction offlineManagerAction = _stateHashMap.get(sourceConfig.getUrl());
            if(OfflineErrorCode.InsufficientStorage.equals(errorEvent.getCode())) {
                WritableMap payload = Arguments.createMap();
                payload.putString("errorMessage", errorEvent.getMessage());
                sendEvent("insufficientStorageEvent", payload);
            if(OfflineErrorCode.DownloadFailed.equals(errorEvent.getCode()) || OfflineErrorCode.NoOptionsAvailable.equals(errorEvent.getCode())) {
                WritableMap payload = Arguments.createMap();
                payload.putString("completeURL", sourceConfig.getUrl());

One observation is that we call offlineManagerAction.getOfflineContentManager().release() when onComplete event happens and the setAction is set to Delete.

if (offlineManagerAction != null && offlineManagerAction.getAction().equals(DELETE)) {
            WritableMap payload = Arguments.createMap();
            payload.putString("completeURL", sourceConfig.getUrl());
            sendEvent("onDeleteEvent", payload);

Hi @technology, you are already using the correct API for clearing all the data i.e. offlineContentManager.deletaAll(). I can also not really spot a wrong usage from the snippets you provided here. When calling deleteAll there is no need to delete single tracks, and I would recommend to only call deleteAll if you want to delete everything for that OfflineContentManager.

After the deleteAll call, everything should be purged from the file system. However, interacting with the OfflineContentManager might agian create caches or other files. So if you want to keep it purged, the OfflineContentManager should be not used anymore (besides the release call) after you delete everything.

Do you see any error or warning logs when running your workflow?
I don’t know how all your code interacts with the bitmovin API, but you might try to postpone the release call on the OfflineContentManager maybe you are releasing it too early for some reason? You may not use the component after it is released.