Skip to content

Commit

Permalink
fix(pack-manager): fix backup icon not working
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Nov 17, 2021
1 parent 76c93ff commit e6bc2dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@fortawesome/fontawesome-free": "^5.15.4",
"@release-it/bumper": "^3.0.1",
"@release-it/conventional-changelog": "^3.3.0",
"@types/file-saver": "^2.0.3",
"@types/json-schema": "^7.0.9",
"@types/jszip": "^3.4.1",
"@types/mime-types": "^2.1.1",
Expand All @@ -51,7 +50,6 @@
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"fast-glob": "^3.2.7",
"file-saver": "^2.0.5",
"file-select-dialog": "^1.5.4",
"fs-extra": "^10.0.0",
"fuse.js": "^6.4.6",
Expand Down
17 changes: 14 additions & 3 deletions src/icon-packs/pack-manager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import "./icon.less";

import cls from "classnames";
import { saveAs } from "file-saver";
import Fuse from "fuse.js";
import JSZip from "jszip";
import svg2uri from "mini-svg-data-uri";
import emoji from "node-emoji";
import { EventRef, Events, normalizePath, Notice } from "obsidian";
import { EventRef, Events, normalizePath, Notice, Platform } from "obsidian";
import { basename, join } from "path";
import { ArrayBuffer as AB } from "spark-md5";

Expand Down Expand Up @@ -168,7 +167,19 @@ export default class PackManager extends Events {
for (const filepath of iconlist.files) {
zip.file(basename(filepath), this.vault.adapter.readBinary(filepath));
}
saveAs(await zip.generateAsync({ type: "blob" }), "custom-icons.zip");
const bakFilePath = "custom-icons.zip";
await this.vault.createBinary(
bakFilePath,
await zip.generateAsync({ type: "arraybuffer" }),
);
if (Platform.isDesktopApp) {
this.plugin.app.openWithDefaultApp(bakFilePath);
} else {
new Notice(
`icons have been saved to ${bakFilePath}, ` +
"enable 'Detect all file extension' in 'Files & Links' to visit it",
);
}
}

async addFromFiles(pack: string, files: FileList) {
Expand Down

0 comments on commit e6bc2dc

Please sign in to comment.