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

On Android 14 and 15, Download direcroty auto clear all downloaded files after RNBackgroundDownloader.checkForExistingDownloads() executed #45

Open
pandya293 opened this issue Mar 5, 2025 · 4 comments

Comments

@pandya293
Copy link

pandya293 commented Mar 5, 2025

On Android 14 and 15, Download direcroty auto clear all downloaded files after RNBackgroundDownloader.checkForExistingDownloads() executed

On android OS 14 and 15 after below code execute, It automatacally clear the ols downloaded files from App's Download Directory. I have searched everything, I am stuck with this issue from last 2 days.

let lostTasks = await RNBackgroundDownloader.checkForExistingDownloads(); console.info(Tasks ${lostTasks} was found!); for (let task of lostTasks) { console.info(task); console.info(Task ${task.id} was found!); tasks[task.id] = task; this.attachTask(task); }

App.js code
const _handleAppStateChange = nextAppState => { if ( appState.current.match(/inactive|background/) && nextAppState === 'active' ) { console.log('App has come to the foreground! '); if (Platform.OS === 'android') { downloadService.rehydrate().then(); } }

download.js file code

`
import RNBackgroundDownloader from '@kesha-antonov/react-native-background-downloader'

rehydrate = async () => {
    console.info('looking for existing task');
    let tasks = {};
    let lostTasks = await RNBackgroundDownloader.checkForExistingDownloads();
    console.info(`Tasks ${lostTasks} was found!`);
    for (let task of lostTasks) {
        console.info(task);
        console.info(`Task ${task.id} was found!`);
        tasks[task.id] = task;
        this.attachTask(task);
    }
    this.tasks = tasks;
    return tasks;
};

`

Environment

Environment:
React: 18.3.1
React native: 0.77.0
"@kesha-antonov/react-native-background-downloader": "^3.2.6",

Target Platform:
Android (14.0) & Android (15.0)

Expected Behavior

If any docuement successfuly download then it should not delete file, if any download is fail then only delete it.

Actual Behavior

I am using ReactNativeBlobUtil.fetch('Get', url) to download the file, after successfuly download and open the .PDF file, when app re-launch the app, let lostTasks = await RNBackgroundDownloader.checkForExistingDownloads(); this method automatically delete the all downloaded files.

When I am using same this RNBackgroundDownloader Package for downloading file then file will not remove, If I use diff react-native package to download any document then this line 'RNBackgroundDownloader.checkForExistingDownloads()' will remove that particular file.

Steps to Reproduce

  1. Download .pdf file using any other download package
  2. minimize/close react-native app
  3. relanuch the app, App will make clear the Download directory
  4. in Android Studio LogCat print the below logs
    2025-03-05 16:09:54.288 9955-9963 DownloadManager android.process.media V Deleting /storage/emulated/0/Android/data/com.XXXXXX.xxx/files/Download/SAT_MOKSH.pdf via provider delete
Image

Thank You, Please help me

@pandya293
Copy link
Author

on android OS 13 and less then 13, this issue not facing. Only Android 14 and grater then 14 this issue facing. Please help asap

@pandya293
Copy link
Author

@kesha-antonov can you please check at your end ? why this happen ?

@kesha-antonov
Copy link
Owner

@kesha-antonov can you please check at your end ? why this happen ?

Hi
Right now can't. Too busy on work projects

@pandya293
Copy link
Author

If I use same this package for any download then file will not delete but as I am using react-native-blob-util package for PDF download, file will automatically removed from download direcroty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants