diff --git a/src/ts/drive/drive.ts b/src/ts/drive/drive.ts index 451a26df..3ae41756 100644 --- a/src/ts/drive/drive.ts +++ b/src/ts/drive/drive.ts @@ -130,8 +130,9 @@ export async function syncDrive() { maindb.account.data = await s.json() } const ACCESS_TOKEN = maindb.account.data.access_token - await loadDrive(ACCESS_TOKEN, 'sync') - if(!isEqual(maindb, BackupDb)){ + const d = await loadDrive(ACCESS_TOKEN, 'sync') + const hadNoSync = d === 'noSync' + if((!isEqual(maindb, BackupDb)) || hadNoSync){ BackupDb = cloneDeep(maindb) const files:DriveFile[] = await getFilesInFolder(ACCESS_TOKEN) const fileNames = files.map((d) => { @@ -142,6 +143,12 @@ export async function syncDrive() { let i = 0; for(let asset of assets){ i += 1; + if(hadNoSync){ + alertStore.set({ + type: "wait", + msg: `Uploading Sync Files... (${i} / ${assets.length})` + }) + } const key = asset.name if(!key || !key.endsWith('.png')){ continue @@ -156,6 +163,12 @@ export async function syncDrive() { const keys = await forageStorage.keys() for(let i=0;i { if(mode === 'backup'){ alertStore.set({ type: "wait", @@ -278,6 +292,7 @@ async function loadDrive(ACCESS_TOKEN:string, mode: 'backup'|'sync') { let dbs:[DriveFile,number][] = [] + let noSyncData = true if(mode === 'backup'){ for(const f of files){ @@ -302,8 +317,11 @@ async function loadDrive(ACCESS_TOKEN:string, mode: 'backup'|'sync') { if(isNaN(tm)){ continue } - else if(tm > lastSaved){ - dbs.push([f,tm]) + else{ + if(tm > lastSaved){ + dbs.push([f,tm]) + } + noSyncData = false } } } @@ -312,6 +330,10 @@ async function loadDrive(ACCESS_TOKEN:string, mode: 'backup'|'sync') { }) } + if(noSyncData && mode === 'sync'){ + return 'noSync' + } + if(dbs.length !== 0){ if(mode === 'sync'){ alertStore.set({