add check if server returns a 500 and display error

resolves https://github.com/owncloud/core/issues/17170
This commit is contained in:
Clark Tomlinson 2015-06-26 11:19:59 -04:00
parent ac94126393
commit ca1da0acb7
2 changed files with 19 additions and 0 deletions

View File

@ -1131,6 +1131,14 @@
return false; return false;
} }
// Did share service die or something else fail?
if (result.status === 500) {
// Go home
this.changeDirectory('/');
OC.Notification.show(t('files', 'This directory is unavailable, please check the logs or contact the administrator'));
return false;
}
if (result.status === 404) { if (result.status === 404) {
// go back home // go back home
this.changeDirectory('/'); this.changeDirectory('/');

View File

@ -1290,6 +1290,17 @@ describe('OCA.Files.FileList tests', function() {
fakeServer.respond(); fakeServer.respond();
expect(fileList.getCurrentDirectory()).toEqual('/'); expect(fileList.getCurrentDirectory()).toEqual('/');
}); });
it('switches to root dir when current directory is unavailable', function() {
fakeServer.respondWith(/\/index\.php\/apps\/files\/ajax\/list.php\?dir=%2funexist/, [
500, {
"Content-Type": "application/json"
},
''
]);
fileList.changeDirectory('/unexist');
fakeServer.respond();
expect(fileList.getCurrentDirectory()).toEqual('/');
});
it('shows mask before loading file list then hides it at the end', function() { it('shows mask before loading file list then hides it at the end', function() {
var showMaskStub = sinon.stub(fileList, 'showMask'); var showMaskStub = sinon.stub(fileList, 'showMask');
var hideMaskStub = sinon.stub(fileList, 'hideMask'); var hideMaskStub = sinon.stub(fileList, 'hideMask');