Skip to content

Commit

Permalink
Fix a problem where pagination of results could miss CPO collection
Browse files Browse the repository at this point in the history
If a user had hundreds of files, the naive search for the CPO collection among
all filenames could miss, and cause a new, empty directory to be created.

Now, as long as a user has fewer than <page-limit> code.pyret.org directories,
things will work.  <page-limit> appears to be around 100
  • Loading branch information
jpolitz committed Oct 5, 2014
1 parent 8eb17c7 commit 4a35cd5
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/web/js/programs.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,12 @@ function createProgramCollectionAPI(clientId, apiKey, collectionName, immediate)
function initialize() {
drive = gapi.client.drive;

var list = gQ(drive.files.list({}));
var list = gQ(drive.files.list({
q: "trashed=false and title = '" + collectionName + "' and "+
"mimeType = '" + FOLDER_MIME + "'"
}));
var baseCollection = list.then(function(filesResult) {
var foundCollection = false;
if(filesResult.items) {
filesResult.items.forEach(function(i) {
if(i.mimeType === FOLDER_MIME &&
i.title === collectionName &&
!(i.explicitlyTrashed)) {
foundCollection = i;
}
});
}
var foundCollection = filesResult.items && filesResult.items[0];
var baseCollection;
if(!foundCollection) {
return gQ(
Expand Down

0 comments on commit 4a35cd5

Please sign in to comment.