nodesign / weio

weio
http://we-io.net
128 stars 35 forks source link

Autosave function create .tmp files into /weio #270

Closed ementi closed 8 years ago

ementi commented 8 years ago

When I get any kind of error with my weio, there are a lot of " *.tmp " files created in the root. I am talking about a couple hundred in a few minutes.

ks156 commented 8 years ago

What's the content of these files ? Can you paste one here ?

ementi commented 8 years ago

The content is my code. Exactly my Code of my main.py and index.html. Like Copy & Paste.

ementi commented 8 years ago

Update: Not just when an error occurs. They seem to be randomly created. Not at every error, just sometimes. AND not every time but sometimes when running a program.

ks156 commented 8 years ago

The autosave function create a temporary file each 4 seconds. This is really bad for the flash memory. In addition, in some cases (I didn't find the conditions yet), the temporary files are not moved or deleted, probably due to this exception which only catch on NameError.

A solution must be found quickly to fix this problem.

drasko commented 8 years ago

@ukicar please think to completely disable autosave function. Saving all the time something to the flash wears the flash, as it has a limited number of writes. If something has to be saved temporarely, you must always use RAM.

But I think for this purpose, it would be best to remove auto-save option all together.

@nmarcetic opinions?

ks156 commented 8 years ago

:+1: to remove auto-save

We can keep the CTRL-S function, and modify writeRawContentToFile either that way

def saveRawContentToFile(path, data):
    try :
        inputFile = open(path, 'w')
        print(inputFile)
        ret = inputFile.write(data)
        inputFile.close()
    except:
        return -1

    return 0

or that way :

def saveRawContentToFile(path, data):
    tmp = "/tmp/"+str(uuid.uuid1())+".tmp"

    try :
        inputFile = open(tmp, 'w')
        print(inputFile)
        ret = inputFile.write(data)
        inputFile.close()
    except:
        os.remove(tmp)
        return -1

    move(tmp, path)
    return 0
ukicar commented 8 years ago

This is extremely critical bug. I decided to really deactivate autoSave as it's not really necessary. When we want to play it will save, when we want to change the project it will save it first (I just added this feature) and when we preview it will save it. Finally we can manually save by CTRL-S. It's pretty enough i think

Thanks Paul for your propositions specially about saving to the temp before copying to the flash (I integrated that too).

Deactivating AutoSave in JS https://github.com/nodesign/weio/commit/1a7bde3578c1270230a808f815a4e84c3cf3f875

Save project before changing the project or creating new etc.. https://github.com/nodesign/weio/commit/b34f0371650512e47f19c779a7c0b5f4dcc3338b

Copy to the /tmp before copying to the flash https://github.com/nodesign/weio/commit/9b33cdc73f1388c9f62f67ea6c75e57d29a0a9a8

@ks156 @drasko For me it's OK I tested. Please confirm that is ok before closing this bug

ks156 commented 8 years ago

Ok for me. Thanks