Skip to content

Commit c339dfc

Browse files
committed
fix(diff): Alert empty file when diff
1 parent bfca2bd commit c339dfc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export default class InvioPlugin extends Plugin {
105105

106106
async viewFileDiff(filePath: string, diffType: TDiffType) {
107107
const file = this.app.vault.getAbstractFileByPath(filePath)
108+
if (!this.app.vault.adapter.exists(filePath)) {
109+
new Notice(`The file(${filePath}) does not exist locally`)
110+
return;
111+
}
108112
if (!(file instanceof TFile)) {
109113
new Notice('Not valid file');
110114
return;
@@ -122,8 +126,15 @@ export default class InvioPlugin extends Plugin {
122126
client,
123127
this.app.vault,
124128
this.settings.password
125-
);
129+
).catch(err => {
130+
log.error('fetch remote file failed: ', err);
131+
return null
132+
})
126133
log.info('remote md: ', remoteMD);
134+
if (!remoteMD?.data) {
135+
new Notice(`The file(${filePath}) does not exist remotely`)
136+
return;
137+
}
127138
return new Promise((resolve, reject) => {
128139
openDiffModal(this.app, this, file, {
129140
data: remoteMD.data,

0 commit comments

Comments
 (0)