Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the ViewHistory localStorage (and sessionStorage) key from database to pdfjs.history, and migrate existing data on read (issue 7760) #7793

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions web/view_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ var ViewHistory = (function ViewHistoryClosure() {

if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
sessionStorage.setItem('pdfjsHistory', databaseStr);
sessionStorage.setItem('pdfjs.history', databaseStr);
} else {
localStorage.setItem('database', databaseStr);
localStorage.setItem('pdfjs.history', databaseStr);
}
resolve();
}.bind(this));
Expand All @@ -87,9 +87,28 @@ var ViewHistory = (function ViewHistoryClosure() {
return new Promise(function (resolve) {
if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
resolve(sessionStorage.getItem('pdfjsHistory'));
resolve(sessionStorage.getItem('pdfjs.history'));
} else {
resolve(localStorage.getItem('database'));
var value = localStorage.getItem('pdfjs.history');

// TODO: Remove this key-name conversion after a suitable time-frame.
// Note that we only remove the old 'database' entry if it looks like
// it was created by PDF.js. to avoid removing someone else's data.
if (!value) {
var databaseStr = localStorage.getItem('database');
if (databaseStr) {
try {
var database = JSON.parse(databaseStr);
if (typeof database.files[0].fingerprint === 'string') {
localStorage.setItem('pdfjs.history', databaseStr);
localStorage.removeItem('database');
value = databaseStr;
}
} catch (ex) { }
}
}

resolve(value);
}
});
},
Expand Down