Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #30357 from asutherland/email-bug1169589
Browse files Browse the repository at this point in the history
Bug 1169589 - [email/backed] Folder depths are wrong because of mismatched argument call lists and type coercion. r=mcav
  • Loading branch information
asutherland committed Jun 2, 2015
2 parents 1a4ea7c + 1628c03 commit 5c0344c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion apps/email/js/ext/imap/account.js
Expand Up @@ -732,7 +732,7 @@ var properties = {
});
}

walkBoxes(boxesRoot.children, '', 0, null);
walkBoxes(boxesRoot.children, 0, null);

// - detect deleted folders
// track dead folder id's so we can issue a
Expand Down
28 changes: 17 additions & 11 deletions apps/email/js/ext/imap/jobs.js
Expand Up @@ -1028,17 +1028,23 @@ ImapJobDriver.prototype = {

var addBoxCallback = function(err, alreadyExists) {
if (err) {
logic(scope, 'createFolderErr', { err: err });
// TODO: do something clever in terms of making sure the folder didn't
// already exist and the server just doesn't like to provide the
// ALREADYEXISTS response.
//
// For now, give up immediately on the folder for safety.
// ensureEssentialFolders is the only logic that creates folders and it
// does not know about existing/pending createFolder requests, so it's
// for the best if we simply give up permanently on this.
done('failure-give-up', null);
return;
// upgrade error message that contain "already" to mean ALREADYEXISTS.
// TODO: make hoodiecrow support ALREADYEXISTS
if (err.message && /already/i.test(err.message)) {
alreadyExists = true;
} else {
logic(scope, 'createFolderErr', { err: err });
// TODO: do something clever in terms of making sure the folder didn't
// already exist and the server just doesn't like to provide the
// ALREADYEXISTS response.
//
// For now, give up immediately on the folder for safety.
// ensureEssentialFolders is the only logic that creates folders and it
// does not know about existing/pending createFolder requests, so it's
// for the best if we simply give up permanently on this.
done('failure-give-up', null);
return;
}
}

logic(scope, 'createdFolder', { alreadyExists: alreadyExists });
Expand Down
21 changes: 15 additions & 6 deletions apps/email/js/ext/logic.js
Expand Up @@ -394,7 +394,7 @@ define(function(require) {
' to not occur (failIfMatched ' + this.matcher + ').';
} else {
return 'MismatchError: expected ' + this.event +
' to match ' + this.matcher + '.';
' to match ' + JSON.stringify(this.matcher.detailPredicate) + '.';
}
}}
});
Expand Down Expand Up @@ -425,10 +425,12 @@ define(function(require) {

logic.defineScope(this, 'LogicMatcher');

var prevPromise = opts.prevPromise || Promise.resolve();
var hasPrevPromise = !!opts.prevPromise;
var normalizedPrevPromise = opts.prevPromise || Promise.resolve();

if (this.not) {
this.promise = prevPromise.then(() => {
// XXX this should probably bind instantly like the next case.
this.promise = normalizedPrevPromise.then(() => {
this.capturedLogs.some((event) => {
if ((!this.ns || event.namespace === this.ns) &&
event.matches(this.type, this.detailPredicate)) {
Expand All @@ -442,6 +444,13 @@ define(function(require) {
// subscribe to a following match.
var subscribeToNextMatch = () => {
var timeoutId = setTimeout(() => {
logic(this, 'failedMatch',
{
ns: this.ns,
type: this.type,
detailPredicate: this.detailPredicate,
capturedLogs: this.capturedLogs
});
reject(new Error('LogicMatcherTimeout: ' + this));
}, this.timeoutMS);

Expand Down Expand Up @@ -514,8 +523,8 @@ define(function(require) {
}
}

if (prevPromise) {
prevPromise.then(subscribeToNextMatch, (e) => reject(e) );
if (hasPrevPromise) {
normalizedPrevPromise.then(subscribeToNextMatch, (e) => reject(e) );
} else {
try {
subscribeToNextMatch();
Expand All @@ -527,7 +536,7 @@ define(function(require) {
} else {
// This is the '.then()' case; we still want to return a
// LogicMatcher so they can chain, but without any further expectations.
this.promise = prevPromise;
this.promise = normalizedPrevPromise;
}
}

Expand Down

0 comments on commit 5c0344c

Please sign in to comment.