+ /**
+ * Publishes the archive to a host using rsync. Currently assumes
+ * gemlog archive.
+ *
+ * @function publishArchive
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async publishArchive(host) {
+
+ internals.debuglog(`Publishing archive to ${host}`);
+ try {
+ await internals.exec('which rsync');
+ }
+ catch (err) {
+ console.error('Please install rsync to publish the archive.');
+ }
+
+ try {
+ internals.debuglog(`Copying archive from ${this.archiveOutputDirectory}`);
+ await internals.exec(`rsync -r ${this.archiveOutputDirectory}/ ${host}`);
+ }
+ catch (err) {
+ console.error('Failed to publish archive');
+ console.error(err.stderr);
+ }
+
+ internals.debuglog('Finished publishing');
+ }
+
+ /**
+ * Adds a remote
+ *
+ * @function addRemote
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async addRemote(remote) {
+
+ await ensureDirectoryExists(this.configDirectory);
+ await Remote.add(this.remoteConfig, remote);
+ }
+
+ /**
+ * Removes a remote
+ *
+ * @function removeRemote
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async removeRemote() {
+
+ await Remote.remove(this.remoteConfig);
+ }
+
+
+ /**
+ * Pulls the posts and archive from the remote
+ *
+ * @function syncDown
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async syncDown() {
+
+ internals.debuglog('Pulling remote state');
+ await ensureDirectoryExists(this.dataDirectory);
+ await Remote.syncDown(this.remoteConfig, this.dataDirectory);
+ internals.debuglog('Pulled remote state');
+ }
+
+ /**
+ * Pushes the posts and archive to the remote
+ *
+ * @function syncUp
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async syncUp() {
+
+ internals.debuglog('Pushing remote state');
+ await ensureDirectoryExists(this.dataDirectory);
+ await Remote.syncUp(this.remoteConfig, this.dataDirectory);
+ internals.debuglog('Pushed remote state');
+ }
+
+ // Adds the passed path to slot 0, and generates files.
+
+ async _update(postLocation) {
+
+ const metadata = await this._getMetadata();
+ await ensureDirectoryExists(this.postsDirectory);
+ await this._copyPost(postLocation);
+ await this._writeMetadata(metadata);
+
+ await this._archive(postLocation);
+
+ await this.generate();
+ try {
+ await this.syncUp();
+ }
+ catch {}
+ }
+
+