tonistiigi / mega

THIS REPO IS NOT MAINTAINED. Unofficial Node.js SDK for Mega
http://tonistiigi.github.com/mega
117 stars 33 forks source link

TypeError: Cannot read property 'children' of undefined #4

Open GoNode5 opened 11 years ago

GoNode5 commented 11 years ago

chrome latest... "version": "0.0.9",

F:\html5\mega\node_modules\mega-master>node example\list xx@gmail.com *passwrd

F:\html5\mega\node_modules\mega-master\lib\storage.js:246 if (!parent.children) parent.children = [] ^ TypeError: Cannot read property 'children' of undefined at Storage._importFile (F:\html5\mega\node_modules\mega-master\lib\storage.j s:246:18) at Array.forEach (native) at Storage.reload.api.on.deleted (F:\html5\mega\node_modules\mega-master\lib \storage.js:174:16) at Request.API.request as _callback at Request.init.self.callback (F:\html5\mega\node_modules\mega-master\node_m odules\request\main.js:122:22) at Request.EventEmitter.emit (events.js:99:17) at Request. (F:\html5\mega\node_modules\mega-master\node_modules\ request\main.js:661:16) at Request.EventEmitter.emit (events.js:126:20) at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (F: \html5\mega\node_modules\mega-master\node_modules\request\main.js:623:14) at IncomingMessage.EventEmitter.emit (events.js:126:20)

tonistiigi commented 11 years ago

Not sure what may cause this. Maybe file appears before its parent(haven't seen such case myself).

If you can debug it then just return out in https://github.com/tonistiigi/mega/blob/master/lib/storage.js#L246 when there is no parent and later inspect the storage.files object to see it there are files that don't have a parent. If not then its a ordering issue and can be fixed.

anolek commented 11 years ago

"version": "0.1.1"

Hi,

I have also this issue, so i output storage.files, and there is no parent. To reproduce this issue, i delete a directory

variable "p" of _importFiles :

{ h: 'rdVEVTiZ', p: 'mFkh1RxI', u: 'J-GtGJoiX60', t: 1, ... su: 'J-GtGJoiX60', sk: 'skWo9a9jTY18NEeuZDNC3g', ts: 1370952694 }

storage.files :

files: { rdVEVTiZ: { downloadId: undefined, key: <Buffer ba 95 52 fb 96 f4 d2 6e a8 8d 47 ad 7d 14 fa 49>, api: [Object], nodeId: 'rdVEVTiZ', timestamp: 1370952694, type: 1, directory: true, size: 0 } },

In my account, i have :

Cloud Drive | -- "Directory 1" | -- "Directory 2 (shared with others contacts)" <-- here "mFkh1RxI" | -- "Directory 3"

I remove "Directory 2" ( with id = "mFkh1RxI" ) So all files in this directory should not exist ( "rdVEVTiZ" doesn't exist anymore)

And i have this issue. But it's ok if it just once. But this issue stay at last 15~30 minutes until it find that "directory 2" doesn't exist anymore. I don't know if it's Mega API or nodeJS cache or something else. I try to figure and i try to make a test case.