Skip to content

Commit

Permalink
prevent stalling initial 'making smart connections' process by improv…
Browse files Browse the repository at this point in the history
…ing meta change detection
  • Loading branch information
brianpetro committed Jun 24, 2024
1 parent 80b0492 commit b2cc63e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions smart-entities/smart_entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,22 @@ class SmartNote extends SmartEntity {
get blocks() { return Object.keys(this.last_history.blocks).map(block_key => this.env.smart_blocks.get(block_key)).filter(block => block); } // filter out blocks that don't exist
get embed_input() { return this._embed_input ? this._embed_input : this.get_embed_input(); }
get meta_changed() {
if(!this.last_history) return true;
if((this.last_history?.mtime || 0) < this.t_file.stat.mtime){
const size_diff = Math.abs(this.last_history.size - this.t_file.stat.size);
console.log("mtime changed: ", this.last_history, this.t_file);
const size_diff_ratio = size_diff / this.last_history.size;
console.log("size diff ratio: ", size_diff_ratio);
if(size_diff_ratio > 0.03) return true; // if size diff greater than 5% of last_history.size, assume file changed
try{
if(!this.last_history) return true;
if(!this.t_file) return true;
if((this.last_history?.mtime || 0) < this.t_file.stat.mtime){
const size_diff = Math.abs(this.last_history.size - this.t_file.stat.size);
console.log("mtime changed: ", this.last_history, this.t_file);
const size_diff_ratio = size_diff / this.last_history.size;
console.log("size diff ratio: ", size_diff_ratio);
if(size_diff_ratio > 0.03) return true; // if size diff greater than 5% of last_history.size, assume file changed
}
// return (this.last_history.mtime !== this.t_file.stat.mtime) && (this.last_history.size !== this.t_file.stat.size);
return false;
}catch(e){
console.warn("error getting meta changed for ", this.data.path, ": ", e);
return true;
}
// return (this.last_history.mtime !== this.t_file.stat.mtime) && (this.last_history.size !== this.t_file.stat.size);
return false;
}
get is_canvas() { return this.data.path.endsWith("canvas"); }
get is_excalidraw() { return this.data.path.endsWith("excalidraw.md"); }
Expand Down

0 comments on commit b2cc63e

Please sign in to comment.