Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,6 @@ android/app/release-key.jks
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn.lock
yarn.lock

.env
27 changes: 13 additions & 14 deletions src/utils/exportSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ export class ExportScheduleUtility {
console.log('Starting export with selectedRegisters:', this.selectedRegisters);
console.log('Available registers:', Object.keys(this.registers));

// Check storage permission first
const hasPermission = await this.checkStoragePermission();
if (!hasPermission) {
Alert.alert('Permission Denied', 'Storage permission is required to save CSV files.');
return null;
}
// No permission needed for app-specific external storage on Android 13+

if (this.selectedRegisters.length === 0) {
Alert.alert('Export Failed', 'No registers selected for export.');
Expand Down Expand Up @@ -86,16 +81,20 @@ export class ExportScheduleUtility {
return null;
}

const path = `${RNFS.DownloadDirectoryPath}/${fileName}`;
console.log('Export path:', path);

// Ensure the directory exists
const dirPath = RNFS.DownloadDirectoryPath;
const dirExists = await RNFS.exists(dirPath);
// WhatsApp-like: Save in Android/media/com.schedulex/ScheduleX
console.log('RNFS.ExternalStorageDirectoryPath:', RNFS.ExternalStorageDirectoryPath);
const scheduleXDir = `${RNFS.ExternalStorageDirectoryPath}/Android/media/com.schedulex/ScheduleX`;
const dirExists = await RNFS.exists(scheduleXDir);
if (!dirExists) {
await RNFS.mkdir(dirPath);
try {
await RNFS.mkdir(scheduleXDir);
console.log('Created folder:', scheduleXDir);
} catch (e) {
console.error('Error creating folder:', e);
}
}

const path = `${scheduleXDir}/${fileName}`;
console.log('Export path:', path);
const exists = await RNFS.exists(path);

if (checkOnly && exists) {
Expand Down