From 37a801332f540baf40429e39074e9b6bbc312bae Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sun, 14 Jan 2024 16:19:00 +0800 Subject: [PATCH] vault might be undefined --- src/remoteForDropbox.ts | 4 ++-- src/remoteForOnedrive.ts | 4 ++-- src/remoteForS3.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/remoteForDropbox.ts b/src/remoteForDropbox.ts index aec617c..4a89f6d 100644 --- a/src/remoteForDropbox.ts +++ b/src/remoteForDropbox.ts @@ -542,8 +542,8 @@ export const uploadToRemote = async ( let mtime = 0; let ctime = 0; - const s = await vault.adapter.stat(fileOrFolderPath); - if (s !== null) { + const s = await vault?.adapter?.stat(fileOrFolderPath); + if (s !== undefined && s !== null) { mtime = Math.round(s.mtime / 1000.0) * 1000; ctime = Math.round(s.ctime / 1000.0) * 1000; } diff --git a/src/remoteForOnedrive.ts b/src/remoteForOnedrive.ts index f2f14a8..1776f8a 100644 --- a/src/remoteForOnedrive.ts +++ b/src/remoteForOnedrive.ts @@ -699,8 +699,8 @@ export const uploadToRemote = async ( let mtime = 0; let ctime = 0; - const s = await vault.adapter.stat(fileOrFolderPath); - if (s !== null) { + const s = await vault?.adapter?.stat(fileOrFolderPath); + if (s !== undefined && s !== null) { mtime = s.mtime; ctime = s.ctime; } diff --git a/src/remoteForS3.ts b/src/remoteForS3.ts index 5803d50..eacdc32 100644 --- a/src/remoteForS3.ts +++ b/src/remoteForS3.ts @@ -366,8 +366,8 @@ export const uploadToRemote = async ( // folder let mtime = 0; let ctime = 0; - const s = await vault.adapter.stat(fileOrFolderPath); - if (s !== null) { + const s = await vault?.adapter?.stat(fileOrFolderPath); + if (s !== undefined && s !== null) { mtime = s.mtime; ctime = s.ctime; } @@ -408,8 +408,8 @@ export const uploadToRemote = async ( ctime = rawContentCTime; } else { localContent = await vault.adapter.readBinary(fileOrFolderPath); - const s = await vault.adapter.stat(fileOrFolderPath); - if (s !== null) { + const s = await vault?.adapter?.stat(fileOrFolderPath); + if (s !== undefined && s !== null) { mtime = s.mtime; ctime = s.ctime; }