Skip to content

Commit

Permalink
Merge 60c3b35 into 009cfeb
Browse files Browse the repository at this point in the history
  • Loading branch information
ifirmawan committed Jul 25, 2023
2 parents 009cfeb + 60c3b35 commit 7e187c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/lib/__test__/cascades.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jest.mock('expo-file-system', () => ({
deleteAsync: jest.fn(async (fileUri) => true),
}));

const DIR_NAME = 'Cascades';
const DIR_NAME = 'SQLite';

describe('cascades', () => {
it('should create the sqlite directory if it does not exist', async () => {
Expand Down
8 changes: 5 additions & 3 deletions app/src/lib/cascades.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as FileSystem from 'expo-file-system';
import * as SQLite from 'expo-sqlite';
import { conn, query } from '../database';

const DIR_NAME = 'Cascades';
const DIR_NAME = 'SQLite';

const createSqliteDir = async () => {
/**
Expand Down Expand Up @@ -37,8 +37,10 @@ const loadDataSource = async (source) => {
const dropFiles = async () => {
const Sqlfiles = await FileSystem.readDirectoryAsync(FileSystem.documentDirectory + DIR_NAME);
Sqlfiles.forEach(async (file) => {
const fileUri = FileSystem.documentDirectory + `${DIR_NAME}/${file}`;
await FileSystem.deleteAsync(fileUri);
if (file.includes('sqlite')) {
const fileUri = FileSystem.documentDirectory + `${DIR_NAME}/${file}`;
await FileSystem.deleteAsync(fileUri);
}
});
return Sqlfiles;
};
Expand Down
1 change: 1 addition & 0 deletions app/src/pages/AuthForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const AuthForm = ({ navigation }) => {
api.setToken(bearerToken);
await crudConfig.updateConfig({ authenticationCode: passcode });
}
await cascades.createSqliteDir();
// save forms
await data.formsUrl.forEach(async (form) => {
// Fetch form detail
Expand Down

0 comments on commit 7e187c6

Please sign in to comment.