fix: restore zip naming conventions from 3.3.x
This commit is contained in:
@@ -29,28 +29,15 @@ export class ArchiveManager {
|
|||||||
const intent = encrypted
|
const intent = encrypted
|
||||||
? EncryptionIntent.FileEncrypted
|
? EncryptionIntent.FileEncrypted
|
||||||
: EncryptionIntent.FileDecrypted;
|
: EncryptionIntent.FileDecrypted;
|
||||||
const data = await this.itemsData(items, intent)
|
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
|
const data = await this.itemsData(items, intent);
|
||||||
this.downloadData(
|
this.downloadData(
|
||||||
data!,
|
data!,
|
||||||
`Standard Notes Encrypted Backup - ${this.formattedDate()}.txt`
|
`Standard Notes Encrypted Backup and Import File - ${this.formattedDate()}.txt`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const data = await this.application.createBackupFile(items, intent);
|
/** download as zipped plain text files */
|
||||||
if (data) {
|
this.downloadZippedItems(items);
|
||||||
/** download as zipped plain text files */
|
|
||||||
this.downloadZippedItems(
|
|
||||||
items,
|
|
||||||
/** Add the backup file to the archive */
|
|
||||||
(zipWriter, zip) => new Promise((resolve) => {
|
|
||||||
const blob = new Blob([data], { type: 'text/plain' });
|
|
||||||
const fileName = zippableTxtName(
|
|
||||||
`Standard Notes Decrypted Backup - ${this.formattedDate()}`
|
|
||||||
);
|
|
||||||
zipWriter.add(fileName, new zip.BlobReader(blob), resolve);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,14 +96,22 @@ export class ArchiveManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async downloadZippedItems(
|
private async downloadZippedItems(
|
||||||
items: SNItem[],
|
items: SNItem[]
|
||||||
onOpenZip: (zipWriter: any, zip: any) => Promise<void>
|
|
||||||
) {
|
) {
|
||||||
await this.loadZip();
|
await this.loadZip();
|
||||||
this.zip.createWriter(
|
this.zip.createWriter(
|
||||||
new this.zip.BlobWriter('application/zip'),
|
new this.zip.BlobWriter('application/zip'),
|
||||||
async (zipWriter: any) => {
|
async (zipWriter: any) => {
|
||||||
await onOpenZip(zipWriter, this.zip);
|
|
||||||
|
const data = await this.application.createBackupFile(items, EncryptionIntent.FileDecrypted);
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
const blob = new Blob([data!], { type: 'text/plain' });
|
||||||
|
const fileName = zippableTxtName(
|
||||||
|
'Standard Notes Backup and Import File.txt'
|
||||||
|
);
|
||||||
|
zipWriter.add(fileName, new this.zip.BlobReader(blob), resolve);
|
||||||
|
});
|
||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
const nextFile = () => {
|
const nextFile = () => {
|
||||||
const item = items[index];
|
const item = items[index];
|
||||||
@@ -133,7 +128,7 @@ export class ArchiveManager {
|
|||||||
name = '';
|
name = '';
|
||||||
}
|
}
|
||||||
const blob = new Blob([contents], { type: 'text/plain' });
|
const blob = new Blob([contents], { type: 'text/plain' });
|
||||||
const fileName = item.content_type + '/' +
|
const fileName = `Items/${item.content_type}/` +
|
||||||
zippableTxtName(name, `-${item.uuid.split('-')[0]}`);
|
zippableTxtName(name, `-${item.uuid.split('-')[0]}`);
|
||||||
zipWriter.add(fileName, new this.zip.BlobReader(blob), () => {
|
zipWriter.add(fileName, new this.zip.BlobReader(blob), () => {
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
Reference in New Issue
Block a user