aboutsummaryrefslogtreecommitdiff
path: root/lib/blog.js
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2022-12-09 18:07:29 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2022-12-09 18:07:29 +0100
commitbd8c1fa2774b98b22939d60c06a06525691867ce (patch)
tree64346534a72b940bade7d5370c2b246a01105a60 /lib/blog.js
parentc5cbbd3835ccd509179504cdf7d5e74356d7dca5 (diff)
Fixes for remote setup
Diffstat (limited to 'lib/blog.js')
-rw-r--r--lib/blog.js42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/blog.js b/lib/blog.js
index ba9ae53..0b291df 100644
--- a/lib/blog.js
+++ b/lib/blog.js
@@ -76,8 +76,10 @@ module.exports = class Blog {
}
catch {};
await this._shift();
- await this._ensurePostsDirectoryExists(join(this.postsDirectory, '0'));
- await this.update(postLocation);
+ const firstDirectory = join(this.postsDirectory, '0');
+ await rm(firstDirectory, { recursive: true, force: true });
+ await this._ensurePostsDirectoryExists(firstDirectory);
+ await this._update(postLocation);
}
/**
@@ -96,18 +98,7 @@ module.exports = class Blog {
await this.syncDown();
}
catch {};
- const metadata = await this._getMetadata();
- await this._ensurePostsDirectoryExists();
- await this._copyPost(postLocation);
- await this._writeMetadata(metadata);
-
- await this._archive(postLocation);
-
- await this.generate();
- try {
- await this.syncUp();
- }
- catch {};
+ const metadata = await this._update();
}
/**
@@ -206,7 +197,9 @@ module.exports = class Blog {
* @instance
*/
async syncDown() {
+ internals.debuglog('Pulling remote state');
await Remote.syncDown(this.remoteConfig, this.blogDirectory)
+ internals.debuglog('Pulled remote state');
}
/**
@@ -218,9 +211,30 @@ module.exports = class Blog {
* @instance
*/
async syncUp() {
+ internals.debuglog('Pushing remote state');
await Remote.syncUp(this.remoteConfig, this.blogDirectory)
+ internals.debuglog('Pushed remote state');
}
+ // Adds the passed path to slot 0, and generates files.
+
+ async _update(postLocation) {
+
+ const metadata = await this._getMetadata();
+ await this._ensurePostsDirectoryExists();
+ await this._copyPost(postLocation);
+ await this._writeMetadata(metadata);
+
+ await this._archive(postLocation);
+
+ await this.generate();
+ try {
+ await this.syncUp();
+ }
+ catch {};
+ }
+
+
// Parses Gemini for each page, copies assets and generates index.
async generate() {