Skip to content

Commit

Permalink
fix: handle _import in warehouse
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jan 12, 2025
1 parent 3825ebe commit e2583ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/hexo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ class Hexo extends EventEmitter {

load(callback?: NodeJSLikeCallback<any>): Promise<any> {
return loadDatabase(this).then(() => {
this._binaryRelationIndex.post_tag.load();
this._binaryRelationIndex.post_category.load();
this.log.info('Start processing');

return Promise.all([
Expand Down
9 changes: 9 additions & 0 deletions lib/models/binary_relation_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class BinaryRelationIndex<K extends PropertyKey, V extends PropertyKey> {
this.ctx = ctx;
}

load() {
this.keyIndex.clear();
this.valueIndex.clear();
const raw = this.ctx.model(this.schemaName).data;
for (const _id in raw) {
this.saveHook(raw[_id]);
}
}

saveHook(data: BinaryRelationType<K, V> & { _id: PropertyKey }) {
const _id = data._id;
const key = data[this.key];
Expand Down

0 comments on commit e2583ac

Please sign in to comment.