Skip to content

Conversation

@robinvd
Copy link
Contributor

@robinvd robinvd commented Apr 1, 2017

Don't know if you already want to implement this, or if this is the best way. But here is my version for multi-upload.

I saw you just updated the repo making mine out of sync. If you want to merge this ill update it. and if you dont, well i had fun making this :).

to test: http://localhost:43110/152qbnvTwEDHoDSecNQhYoR6z78QVLpE4f

@robinvd
Copy link
Contributor Author

robinvd commented Apr 1, 2017

Just noticed that not all files are added to the db. All items read in the db and then write it again, overwriting each other

Copy link
Owner

@Emeraude Emeraude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks interesting.
You should update it to make it compatible with the Emeraude/master branch.

updateMetadata: (e) =>
newdiv = '<div id="tagform">'
for i in e.files
console.log(i)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This king of debug should be removed.

metadata.artist = document.getElementById('artist').value
metadata.title = document.getElementById('title').value
metadata.artist = form[0].value
metadata.title = form[1].value
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Track number should not be dismissed (it will be used later).

@Emeraude
Copy link
Owner

Emeraude commented Apr 2, 2017

Did you manage to figure out why some the db is not correctly updated with your version ?

@Emeraude
Copy link
Owner

Emeraude commented Apr 2, 2017

I think I got it. It's because calls to ZeroNet API are asynchronous, and variable i at line 129 is overwrited.

@robinvd
Copy link
Contributor Author

robinvd commented Apr 2, 2017

That is the issue i first ran into, but line 135 uses the "do" which makes the variables "metadata, path, i" static to the inner part (not sure if clear enough). I think the problem is: In line 140 it reads the file contents.json, if all iteration read the file, change it and write it back. they only write their own modifications

@Emeraude
Copy link
Owner

Emeraude commented Apr 2, 2017

Yes, that's probably true.

@robinvd
Copy link
Contributor Author

robinvd commented Apr 2, 2017

Maybe its a good idea to only start uploading the next one when the first one is done. and keep the contents.json in mem while uploading.

@Emeraude
Copy link
Owner

Emeraude commented Apr 2, 2017

We can upload all the files at the same time, but we have to update the data.json file only once.

@robinvd
Copy link
Contributor Author

robinvd commented Apr 2, 2017

Maybe:

var toUpload = e.files.length

and at the end of the callback:

toUpload -= 1
if toUpload == 0
  writetofile
  playSong()

@Emeraude
Copy link
Owner

Emeraude commented Apr 7, 2017

I'd be happy to merge this PR if you correct the bug with that piece of code above, and if you correct the conflicts with the Emeraude/master branch (it's only about the track hidden field, which is missing in your PR).

@robinvd
Copy link
Contributor Author

robinvd commented Apr 8, 2017

Will do that, after my exams.

@Emeraude
Copy link
Owner

Are you still working on it?

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

Successfully merging this pull request may close these issues.

2 participants