Skip to content

Commit 7dcab74

Browse files
committed
enhance uploads speed
1 parent e4a3b58 commit 7dcab74

5 files changed

Lines changed: 35 additions & 43 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "mdfriday",
33
"name": "Friday",
4-
"version": "0.11.3",
4+
"version": "0.11.4",
55
"minAppVersion": "0.15.0",
66
"description": "Notes to Website. Friday helps you turn Markdown documents into websites in minutes.",
77
"author": "sunwei",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-friday-plugin",
3-
"version": "0.11.3",
3+
"version": "0.11.4",
44
"description": "Friday is an Obsidian plugin that empowers users to focus on content creation by writing Markdown files, while we handle the distribution. From creating websites to content deployment, Friday serves as a creative output assistant, helping users turn their work into publishable sites with ease.",
55
"main": "main.js",
66
"scripts": {

src/ftp.ts

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -540,72 +540,59 @@ export class FTPUploader {
540540
}
541541
}
542542

543-
// Delete obsolete files first
543+
// Delete obsolete files first (best effort, don't block upload on deletion errors)
544544
if (toDelete.length > 0) {
545+
console.log(`[FTP Incremental] 🗑️ Attempting to delete ${toDelete.length} obsolete files...`);
545546
for (const filePath of toDelete) {
546547
try {
547-
await this.client.remove(filePath);
548+
// Use absolute remote path for deletion
549+
const remoteFilePath = this.config.remoteDir && this.config.remoteDir !== '/'
550+
? `${this.config.remoteDir}/${filePath}`.replace(/\\/g, '/')
551+
: filePath.replace(/\\/g, '/');
552+
await this.client.remove(remoteFilePath);
548553
} catch (err) {
549-
console.warn(`[FTP Incremental] - Failed to delete ${filePath}:`, err);
554+
// Deletion errors are non-critical - just log and continue
555+
// The main goal is to upload new/updated files successfully
556+
console.error(`[FTP Incremental] - ⚠️ Failed to delete ${filePath} (non-critical):`, err);
550557
}
551558
}
552559
}
553560

554561
// Track created directories to avoid repeated creation attempts
555562
const createdDirs = new Set<string>();
556-
563+
557564
for (const filePath of toUpload) {
558565
const localFilePath = path.join(localDir, filePath);
559-
const remoteFilePath = filePath;
560-
566+
// Use absolute remote path: base directory + relative path
567+
const remoteFilePath = this.config.remoteDir && this.config.remoteDir !== '/'
568+
? `${this.config.remoteDir}/${filePath}`.replace(/\\/g, '/')
569+
: filePath.replace(/\\/g, '/');
570+
561571
// Ensure remote directory exists
562572
const remoteDir = path.dirname(remoteFilePath).replace(/\\/g, '/');
563573
if (remoteDir && remoteDir !== '.' && remoteDir !== '/') {
564574
if (!createdDirs.has(remoteDir)) {
565575
try {
566-
// Split path and create directories one by one
567-
const parts = remoteDir.split('/').filter(p => p);
568-
let currentPath = '';
569-
570-
for (const part of parts) {
571-
currentPath = currentPath ? `${currentPath}/${part}` : part;
572-
573-
if (!createdDirs.has(currentPath)) {
574-
try {
575-
// Try to create directory
576-
await this.client.ensureDir(currentPath);
577-
createdDirs.add(currentPath);
578-
} catch (err) {
579-
// Directory might already exist, try to cd into it
580-
try {
581-
await this.client.cd(currentPath);
582-
createdDirs.add(currentPath);
583-
} catch (cdErr) {
584-
console.error(`[FTP Incremental] - Failed to ensure dir ${currentPath}:`, err);
585-
throw new Error(`Cannot create or access directory: ${currentPath}`);
586-
}
587-
}
588-
}
589-
}
590-
591-
// Go back to base directory
592-
if (this.config.remoteDir && this.config.remoteDir !== '/') {
593-
await this.client.cd(this.config.remoteDir);
594-
}
595-
576+
// Use ensureDir with absolute path - it will create all parent directories
577+
await this.client.ensureDir(remoteDir);
596578
createdDirs.add(remoteDir);
597579
} catch (err) {
598-
console.error(`[FTP Incremental] - Failed to ensure directory ${remoteDir}:`, err);
599-
throw err;
580+
// Directory creation failed, but try to continue
581+
// The upload might still succeed if directory already exists
582+
console.error(`[FTP Incremental] - ⚠️ Failed to ensure directory ${remoteDir}:`, err);
583+
console.error(`[FTP Incremental] - Will attempt upload anyway...`);
600584
}
601585
}
602586
}
603587

604-
// Upload file
588+
// Upload file (this is the critical operation)
605589
try {
606590
await this.client.uploadFrom(localFilePath, remoteFilePath);
607591
} catch (err) {
608-
console.error(`[FTP Incremental] - Failed to upload ${filePath}:`, err);
592+
console.error(`[FTP Incremental] - ❌ Upload failed for ${filePath}:`, err);
593+
console.error(`[FTP Incremental] - Local path: ${localFilePath}`);
594+
console.error(`[FTP Incremental] - Remote path: ${remoteFilePath}`);
595+
// Upload failure is critical - throw error to stop the process
609596
throw err;
610597
}
611598
}

src/svelte/Site.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,10 @@
906906
serverRunning = false;
907907
}
908908
909+
// Clear previous monitoring paths to avoid accumulation across builds
910+
absSelectedFolderPath = [];
911+
absProjContentPath = [];
912+
909913
// Generate random preview ID
910914
previewId = generateRandomId();
911915

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"0.10.22": "0.15.0",
77
"0.11.1": "0.15.0",
88
"0.11.2": "0.15.0",
9-
"0.11.3": "0.15.0"
9+
"0.11.3": "0.15.0",
10+
"0.11.4": "0.15.0"
1011
}

0 commit comments

Comments
 (0)