From 60fc07ee8fdbbbab82174f23aab30d2b7bf53c6f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 19 Jan 2017 14:36:10 +0000 Subject: [PATCH] Add boolean to set/remove/rename in storage --- src/app/storage.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/storage.js b/src/app/storage.js index d0cca22776..6222843d28 100644 --- a/src/app/storage.js +++ b/src/app/storage.js @@ -10,7 +10,12 @@ function Storage () { } this.set = function (name, content) { - window.localStorage.setItem('sol:' + name, content) + try { + window.localStorage.setItem('sol:' + name, content) + } catch (exception) { + return false + } + return true } function safeKeys () { @@ -28,12 +33,16 @@ function Storage () { this.remove = function (name) { window.localStorage.removeItem('sol:' + name) + return true } this.rename = function (originalName, newName) { var content = this.get(originalName) - this.set(newName, content) + if (!this.set(newName, content)) { + return false + } this.remove(originalName) + return true } this.loadFile = function (filename, content) {