Merge lp:~osomon/webbrowser-app/sessionstorage-race into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1383
Merged at revision: 1388
Proposed branch: lp:~osomon/webbrowser-app/sessionstorage-race
Merge into: lp:webbrowser-app
Diff against target: 36 lines (+9/-2)
1 file modified
src/app/session-storage.cpp (+9/-2)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/sessionstorage-race
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+288963@code.launchpad.net

Commit message

Tentative fix for a bug where the session state stored on disk is apparently corrupted, thus discarding the current browsing session.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/session-storage.cpp'
2--- src/app/session-storage.cpp 2014-08-08 15:31:23 +0000
3+++ src/app/session-storage.cpp 2016-03-14 18:36:26 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2014 Canonical Ltd.
7+ * Copyright 2014-2016 Canonical Ltd.
8 *
9 * This file is part of webbrowser-app.
10 *
11@@ -16,7 +16,11 @@
12 * along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14
15+// system
16+#include <cstdio>
17+
18 // Qt
19+#include <QtCore/QDateTime>
20 #include <QtCore/QFile>
21
22 // local
23@@ -73,10 +77,13 @@
24
25 void SessionStorage::store(const QString& data) const
26 {
27- QFile file(m_dataFile);
28+ QString tempName = m_dataFile + "." + \
29+ QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch());;
30+ QFile file(tempName);
31 if (file.open(QIODevice::WriteOnly)) {
32 file.write(data.toUtf8());
33 file.close();
34+ rename(tempName.toUtf8().constData(), m_dataFile.toUtf8().constData());
35 }
36 }
37

Subscribers

People subscribed via source and target branches

to status/vote changes: