Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document save callback didn't execute right after document actually changed #786

Open
funfungo opened this issue Jun 29, 2020 · 0 comments

Comments

@funfungo
Copy link

funfungo commented Jun 29, 2020

I have develop a sketch plugin to upload sketch file to the web server right after the document has been saved
but I found when I run upload method in the callback of document.save, sometimes it upload the original document which is unsaved, then I run some test

 let fileData = fs.readFileSync(decodeURIComponent(document.path));
console.log("1:" +  fileData.length);
//do some actions 
//eg. delete some pages 
....
//save the document
document.save(err => {
   fileData = fs.readFileSync(decodeURIComponent(document.path));
   console.log("2:" + fileData.length);
   setTimeout(() => {
      fileData = fs.readFileSync(decodeURIComponent(document.path));
      console.log("3:" + fileData.length);
   }, 4000)
})

It seems the data length(1 and 2) is actually the same right after the save callback is running, after a 4000ms time out(3) ,the file data is actually changed.

But I think the document is supposed to change right after the callback has been executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant