davidferguson / pibakery

The blocks based, easy to use setup tool for Raspberry Pi
http://www.PiBakery.org
GNU General Public License v3.0
1.49k stars 147 forks source link

Custom block added multiple times #54

Open dsbert opened 8 years ago

dsbert commented 8 years ago

This concerns adding a custom block by dragging the folder into the application window.

The user is allowed to drag the same block multiple times. Each time the block is dropped onto the window, a duplicate is added to the block selection menu. If the block is modified, all of the duplicates appear to update.

I've also noticed that an error is output in the console when dragging a block. It appears the duplicate block check should happen here, but the error is printed instead.

pibakery.js:2397 Error: ENOENT: no such file or directory, stat '/projects/raspberrypi/pibakery/source/pibakery-blocks/mountnfs'(…)(anonymous function) @ pibakery.js:2397
            if (error) {
              console.error(error)
            }
            else {
              var choice = dialog.showMessageBox(
                {
                  type: 'question',
                  buttons: ['Yes', 'No'],
                  title: 'Block Conflict',
                  message: 'The block you are trying to import conflicts with a block already imported into PiBakery. Do you want to overwrite the existing block?'
                })
davidferguson commented 8 years ago

That bit of code is actually there to prevent import conflicts between blocks that you drag in, and blocks that are already in PiBakery from the pibakery-blocks folder, which is why that error is allowed to pass (it's good if it passes).

Currently there's no checking if a dragged-in block already exists, but I'm guessing the best behaviour would be to delete that block, and import the new one, which would effectively update the existing one?