Skip to content

Commit

Permalink
cleanup unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Joseph Petro committed Dec 14, 2024
1 parent c97a64e commit 5051c9b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 65 deletions.
9 changes: 0 additions & 9 deletions smart-collections/adapters/_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@ export class ItemDataAdapter {
*/
get_data_path() { throw new Error('Not implemented'); }

/**
* Overwrite the saved data with the current state of the item. Unlike `save()`, this
* may replace the entire file rather than append. Useful for cleanup or recovery operations.
* @async
* @param {string|null} [ajson=null] - An optional serialized representation of the item’s data.
* @returns {Promise<void>} Resolves when the data is overwritten.
*/
async overwrite_saved_data(ajson = null) { throw new Error('Not implemented'); }

/**
* @returns {CollectionDataAdapter} The collection data adapter that this item data adapter belongs to.
*/
Expand Down
17 changes: 0 additions & 17 deletions smart-collections/adapters/ajson_multi_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,6 @@ export class AjsonMultiFileItemDataAdapter extends FileItemDataAdapter {
this.item.collection.delete_item(this.item.key);
}

async overwrite_saved_data(ajson = null) {
// Overwrite with the current item state if not provided
const data_path = this.get_data_path();
if (!ajson) {
if (!this.item.deleted) {
ajson = this._build_ajson_line(this.item, this.item.data);
} else {
// If deleted, remove file if exists
if (await this.fs.exists(data_path)) {
await this.fs.remove(data_path);
}
return;
}
}
await this.fs.write(data_path, ajson);
}

async _cleanup_deleted_item() {
const data_path = this.get_data_path();
if (await this.fs.exists(data_path)) {
Expand Down
13 changes: 0 additions & 13 deletions smart-collections/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,6 @@ export class CollectionItem {
}
}

/**
* Overwrites the saved data with current state.
* @param {string} [ajson=this.ajson]
* @returns {Promise<void>}
*/
async overwrite_saved_data(ajson = this.ajson) {
try {
await this.data_adapter.fs.write(this.data_path, ajson);
} catch (err) {
console.error(err, err.stack);
}
}

/**
* Queues this item for loading.
*/
Expand Down
19 changes: 0 additions & 19 deletions smart-sources/adapters/data/ajson_multi_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,6 @@ export class AjsonMultiFileSourceDataAdapter extends AjsonMultiFileItemDataAdapt
this.item.collection.delete_item(this.item.key);
}

async overwrite_saved_data(ajson = null) {
// Overwrite with minimal lines:
// One for the source if not deleted, one per non-deleted block
if (!ajson) {
const lines = [];
if (!this.item.deleted) {
lines.push(this._build_ajson_line(this.item, this.item.data));
}
for (const block of this.item.blocks) {
if (!block.deleted) {
lines.push(this._build_ajson_line(block, block.data));
}
}
ajson = lines.join('\n');
}
const data_path = this.get_data_path();
await this.fs.write(data_path, ajson);
}

_parse(ajson) {
const final_states = {};
if (!ajson.length) return { final_states, rewrite_needed: false };
Expand Down
7 changes: 0 additions & 7 deletions smart-sources/smart_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,6 @@ export class SmartSource extends SmartEntity {
// }
// });
// }
// async overwrite_saved_data(ajson = null) {
// if(!ajson) ajson = [
// super.ajson,
// ...this.blocks.map(block => block.ajson).filter(ajson => ajson),
// ].join("\n");
// await super.overwrite_saved_data(ajson);
// }

/**
* Handles errors during the load process.
Expand Down

0 comments on commit 5051c9b

Please sign in to comment.