diff --git a/handler.go b/handler.go index e9541e0..88b6455 100644 --- a/handler.go +++ b/handler.go @@ -71,10 +71,7 @@ func (cui *ConfigUI) GetDelta(w http.ResponseWriter, r *http.Request) { panic(err) } if delta > stat.Size() { - panic(fmt.Errorf("delta(%d) is larger than file size(%d)", delta, stat.Size())) - } - if stat.Size() < delta { - panic(fmt.Errorf("delta(%d) is smaller than file size(%d)", delta, stat.Size())) + panic(fmt.Errorf("delta(%d) is larger than file size(%d), the file might have been changed", delta, stat.Size())) } buf := make([]byte, stat.Size()-delta) _, err = f.ReadAt(buf, delta) diff --git a/templates/base/script.tmpl b/templates/base/script.tmpl index abf725b..71d6cfe 100644 --- a/templates/base/script.tmpl +++ b/templates/base/script.tmpl @@ -83,11 +83,12 @@ async function FileDelta(){ else { const res = await fetch('{{.BaseUrl}}api/delta?f=true&name=' + Active+'&delta='+LastDelta) .catch(err=>{console.log(err);return;}); - const body = await res.json(); if(!res.ok){ - Catch(res) + await Catch(res) + FileGet() return } + const body = await res.json(); LastDelta = body.delta; editor.session.setValue(editor.getValue()+body.data); }