Fix invalid file ID in the drive

pull/1/head
yflory 6 years ago
parent bd190dc73b
commit f5858f524d

@ -626,6 +626,11 @@ define([
var toClean = []; var toClean = [];
for (var id in fd) { for (var id in fd) {
id = Number(id); id = Number(id);
if (!id && id !== 0) {
debug("Invalid file ID in filesData.", id);
toClean.push(id);
continue;
}
var el = fd[id]; var el = fd[id];
// Clean corrupted data // Clean corrupted data

@ -729,6 +729,7 @@ define([
if (type === "pin") { if (type === "pin") {
return function (fileId) { return function (fileId) {
var data = userObject.getFileData(fileId); var data = userObject.getFileData(fileId);
if (!data) { return; }
// Don't pin pads owned by someone else // Don't pin pads owned by someone else
if (_ownedByOther(Env, data.owners)) { return; } if (_ownedByOther(Env, data.owners)) { return; }
// Don't push duplicates // Don't push duplicates

@ -311,12 +311,12 @@ define([
_getFiles[FILES_DATA] = function () { _getFiles[FILES_DATA] = function () {
var ret = []; var ret = [];
if (!files[FILES_DATA]) { return ret; } if (!files[FILES_DATA]) { return ret; }
return Object.keys(files[FILES_DATA]).map(Number); return Object.keys(files[FILES_DATA]).map(Number).filter(Boolean);
}; };
_getFiles[SHARED_FOLDERS] = function () { _getFiles[SHARED_FOLDERS] = function () {
var ret = []; var ret = [];
if (!files[SHARED_FOLDERS]) { return ret; } if (!files[SHARED_FOLDERS]) { return ret; }
return Object.keys(files[SHARED_FOLDERS]).map(Number); return Object.keys(files[SHARED_FOLDERS]).map(Number).filter(Boolean);
}; };
var getFiles = exp.getFiles = function (categories) { var getFiles = exp.getFiles = function (categories) {
var ret = []; var ret = [];

Loading…
Cancel
Save