fix: follow file not updating when file is trunc
parent
04580e4672
commit
0aa278efa0
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue