Merge lp:~charlesk/keeper/remove-abandoned-storage-prototype into lp:keeper

Proposed by Charles Kerr
Status: Merged
Merge reported by: Charles Kerr
Merged at revision: not available
Proposed branch: lp:~charlesk/keeper/remove-abandoned-storage-prototype
Merge into: lp:keeper
Diff against target: 516 lines (+0/-447)
10 files modified
src/CMakeLists.txt (+0/-1)
src/cli/CMakeLists.txt (+0/-1)
src/service/CMakeLists.txt (+0/-1)
src/storage/CMakeLists.txt (+0/-9)
src/storage/internal/local-storage.cpp (+0/-122)
src/storage/internal/local-storage.h (+0/-57)
src/storage/storage-factory.cpp (+0/-94)
src/storage/storage-factory.h (+0/-53)
src/storage/storage.cpp (+0/-36)
src/storage/storage.h (+0/-73)
To merge this branch: bzr merge lp:~charlesk/keeper/remove-abandoned-storage-prototype
Reviewer Review Type Date Requested Status
Xavi Garcia (community) Approve
Review via email: mp+299971@code.launchpad.net

Commit message

remove unnecessary storage interface code.

Description of the change

This MR removes some unnecessary storage interface code that I experimented with briefly before my NOLA trip.

To post a comment you must log in.
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

LGTM

review: Approve
41. By Charles Kerr

sync with trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2016-07-06 19:54:34 +0000
3+++ src/CMakeLists.txt 2016-07-21 04:25:11 +0000
4@@ -4,7 +4,6 @@
5 )
6
7 add_subdirectory(qdbus-stubs)
8-add_subdirectory(storage)
9 add_subdirectory(cli)
10 add_subdirectory(service)
11 add_subdirectory(util)
12
13=== modified file 'src/cli/CMakeLists.txt'
14--- src/cli/CMakeLists.txt 2016-06-08 16:40:34 +0000
15+++ src/cli/CMakeLists.txt 2016-07-21 04:25:11 +0000
16@@ -14,7 +14,6 @@
17
18 target_link_libraries(
19 ${CLI_EXEC}
20- storage
21 util
22 qdbus-stubs
23 Qt5::Core
24
25=== modified file 'src/service/CMakeLists.txt'
26--- src/service/CMakeLists.txt 2016-07-07 13:59:14 +0000
27+++ src/service/CMakeLists.txt 2016-07-21 04:25:11 +0000
28@@ -35,7 +35,6 @@
29 target_link_libraries(
30 ${SERVICE_EXEC}
31 ${SERVICE_LIB}
32- storage
33 util
34 qdbus-stubs
35 storage-framework
36
37=== removed directory 'src/storage'
38=== removed file 'src/storage/CMakeLists.txt'
39--- src/storage/CMakeLists.txt 2016-05-30 02:16:12 +0000
40+++ src/storage/CMakeLists.txt 1970-01-01 00:00:00 +0000
41@@ -1,9 +0,0 @@
42-include_directories(${CMAKE_CURRENT_BINARY_DIR})
43-
44-set(STORAGE_SOURCES
45- storage.cpp
46- internal/local-storage.cpp
47- storage-factory.cpp
48-)
49-
50-add_library(storage STATIC ${STORAGE_SOURCES})
51
52=== removed directory 'src/storage/internal'
53=== removed file 'src/storage/internal/local-storage.cpp'
54--- src/storage/internal/local-storage.cpp 2016-05-30 02:16:12 +0000
55+++ src/storage/internal/local-storage.cpp 1970-01-01 00:00:00 +0000
56@@ -1,122 +0,0 @@
57-/*
58- * Copyright (C) 2016 Canonical, Ltd.
59- *
60- * This program is free software: you can redistribute it and/or modify it
61- * under the terms of the GNU General Public License version 3, as published
62- * by the Free Software Foundation.
63- *
64- * This program is distributed in the hope that it will be useful, but
65- * WITHOUT ANY WARRANTY; without even the implied warranties of
66- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
67- * PURPOSE. See the GNU General Public License for more details.
68- *
69- * You should have received a copy of the GNU General Public License along
70- * with this program. If not, see <http://www.gnu.org/licenses/>.
71- *
72- * Authors:
73- * Charles Kerr <charles.kerr@canonical.com>
74- */
75-
76-#include <storage/internal/local-storage.h>
77-
78-#include <QDir>
79-#include <QStandardPaths>
80-#include <QtDebug>
81-
82-namespace storage
83-{
84-namespace internal
85-{
86-
87-class LocalStorage::Impl
88-{
89-public:
90-
91- Impl()
92- {
93- initBackupsDir();
94- }
95-
96- ~Impl()
97- {
98- }
99-
100- QVector<BackupInfo>
101- getBackups()
102- {
103- return QVector<BackupInfo>();
104- }
105-
106- QSharedPointer<QIODevice>
107- startRestore(const QString& /*uuid*/)
108- {
109- return QSharedPointer<QIODevice>();
110- }
111-
112- QSharedPointer<QIODevice>
113- startBackup(const BackupInfo& /*info*/)
114- {
115- return QSharedPointer<QIODevice>();
116- }
117-
118-private:
119-
120- void
121- initBackupsDir()
122- {
123- static constexpr char const * DIRNAME {"Ubuntu Backups"};
124-
125- auto path = QStandardPaths::locate(QStandardPaths::AppDataLocation,
126- DIRNAME,
127- QStandardPaths::LocateDirectory);
128- if (path.isEmpty())
129- {
130- QDir parent(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
131- parent.mkpath(DIRNAME);
132- path = parent.absoluteFilePath(DIRNAME);
133- }
134-
135- QDir dir(path);
136- if (!dir.exists())
137- qCritical() << path << " should exist but doesn't.";
138-
139- backupsDir_ = dir;
140- }
141-
142- QDir backupsDir_ {};
143-};
144-
145-/***
146-****
147-***/
148-
149-LocalStorage::LocalStorage():
150- impl_{new Impl{}}
151-{
152-}
153-
154-LocalStorage::~LocalStorage()
155-{
156-}
157-
158-QVector<BackupInfo>
159-LocalStorage::getBackups()
160-{
161- return impl_->getBackups();
162-}
163-
164-QSharedPointer<QIODevice>
165-LocalStorage::startRestore(const QString& uuid)
166-{
167- return impl_->startRestore(uuid);
168-}
169-
170-QSharedPointer<QIODevice>
171-LocalStorage::startBackup(const BackupInfo& info)
172-{
173- return impl_->startBackup(info);
174-}
175-
176-} // namespace internal
177-
178-} // namespace storage
179
180=== removed file 'src/storage/internal/local-storage.h'
181--- src/storage/internal/local-storage.h 2016-05-30 02:16:12 +0000
182+++ src/storage/internal/local-storage.h 1970-01-01 00:00:00 +0000
183@@ -1,57 +0,0 @@
184-/*
185- * Copyright (C) 2016 Canonical, Ltd.
186- *
187- * This program is free software: you can redistribute it and/or modify it
188- * under the terms of the GNU General Public License version 3, as published
189- * by the Free Software Foundation.
190- *
191- * This program is distributed in the hope that it will be useful, but
192- * WITHOUT ANY WARRANTY; without even the implied warranties of
193- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
194- * PURPOSE. See the GNU General Public License for more details.
195- *
196- * You should have received a copy of the GNU General Public License along
197- * with this program. If not, see <http://www.gnu.org/licenses/>.
198- *
199- * Authors:
200- * Charles Kerr <charles.kerr@canonical.com>
201- */
202-
203-#pragma once
204-
205-#include <storage/storage.h>
206-
207-#include <memory> // unique_ptr
208-
209-namespace storage
210-{
211-namespace internal
212-{
213-
214-// TODO: use the Qt pimpl macros
215-class LocalStorage final: public Storage
216-{
217-public:
218-
219- LocalStorage();
220- virtual ~LocalStorage();
221-
222- LocalStorage(LocalStorage&&) =delete;
223- LocalStorage(LocalStorage const&) =delete;
224- LocalStorage& operator=(LocalStorage&&) =delete;
225- LocalStorage& operator=(LocalStorage const&) =delete;
226-
227- QVector<BackupInfo> getBackups() override;
228- QSharedPointer<QIODevice> startRestore(const QString& uuid) override;
229- QSharedPointer<QIODevice> startBackup(const BackupInfo& info) override;
230-
231-private:
232-
233- class Impl;
234- friend class Impl;
235- std::unique_ptr<Impl> impl_;
236-};
237-
238-} // namespace internal
239-
240-} // namespace storage
241
242=== removed file 'src/storage/storage-factory.cpp'
243--- src/storage/storage-factory.cpp 2016-05-30 02:16:12 +0000
244+++ src/storage/storage-factory.cpp 1970-01-01 00:00:00 +0000
245@@ -1,94 +0,0 @@
246-/*
247- * Copyright (C) 2016 Canonical, Ltd.
248- *
249- * This program is free software: you can redistribute it and/or modify it
250- * under the terms of the GNU General Public License version 3, as published
251- * by the Free Software Foundation.
252- *
253- * This program is distributed in the hope that it will be useful, but
254- * WITHOUT ANY WARRANTY; without even the implied warranties of
255- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
256- * PURPOSE. See the GNU General Public License for more details.
257- *
258- * You should have received a copy of the GNU General Public License along
259- * with this program. If not, see <http://www.gnu.org/licenses/>.
260- *
261- * Authors:
262- * Charles Kerr <charles.kerr@canonical.com>
263- */
264-
265-#include <storage/storage-factory.h>
266-#include <storage/internal/local-storage.h>
267-
268-#include <QThread>
269-
270-#include <QtConcurrent>
271-#include <QtDebug>
272-
273-namespace storage
274-{
275-
276-class StorageFactory::Impl
277-{
278-public:
279-
280- Impl()
281- {
282- const auto modeStr = QString::fromUtf8(qgetenv("KEEPER_BACKEND"));
283-
284- if (modeStr.isEmpty())
285- mode_ = DEFAULT_MODE;
286- else if (modeStr == "storage-framework")
287- mode_ = Mode::StorageFramework;
288- else if (modeStr == "memory")
289- mode_ = Mode::Memory;
290- else if (modeStr == "local")
291- mode_ = Mode::Local;
292- else {
293- const auto modeStr8 = modeStr.toUtf8();
294- qFatal("Unrecognized keeper backend: %s", modeStr8.constData());
295- }
296- }
297-
298- QFuture<QSharedPointer<Storage>> getStorage()
299- {
300- QFuture<QSharedPointer<Storage>> ret;
301-
302- if (mode_ == Mode::Local)
303- {
304- return QtConcurrent::run([](){
305- return QSharedPointer<Storage>{new internal::LocalStorage{}};
306- });
307- }
308-
309- qWarning() << "storage not created";
310- return QFuture<QSharedPointer<Storage>>();
311- }
312-
313-private:
314-
315- enum class Mode { StorageFramework, Local, Memory };
316- static constexpr Mode DEFAULT_MODE {Mode::Local}; // while under development
317- Mode mode_ {Mode::Local};
318-};
319-
320-/***
321-****
322-***/
323-
324-StorageFactory::StorageFactory():
325- impl_{new Impl{}}
326-{
327-}
328-
329-StorageFactory::~StorageFactory()
330-{
331-}
332-
333-QFuture<QSharedPointer<Storage>>
334-StorageFactory::getStorage()
335-{
336- return impl_->getStorage();
337-}
338-
339-} // namespace storage
340
341=== removed file 'src/storage/storage-factory.h'
342--- src/storage/storage-factory.h 2016-05-30 02:16:12 +0000
343+++ src/storage/storage-factory.h 1970-01-01 00:00:00 +0000
344@@ -1,53 +0,0 @@
345-/*
346- * Copyright (C) 2016 Canonical, Ltd.
347- *
348- * This program is free software: you can redistribute it and/or modify it
349- * under the terms of the GNU General Public License version 3, as published
350- * by the Free Software Foundation.
351- *
352- * This program is distributed in the hope that it will be useful, but
353- * WITHOUT ANY WARRANTY; without even the implied warranties of
354- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
355- * PURPOSE. See the GNU General Public License for more details.
356- *
357- * You should have received a copy of the GNU General Public License along
358- * with this program. If not, see <http://www.gnu.org/licenses/>.
359- *
360- * Authors:
361- * Charles Kerr <charles.kerr@canonical.com>
362- */
363-
364-#pragma once
365-
366-#include "storage/storage.h"
367-
368-#include <QFuture>
369-#include <QSharedPointer>
370-
371-namespace storage
372-{
373-
374-class StorageFactory
375-{
376-public:
377-
378- StorageFactory();
379- ~StorageFactory();
380-
381- StorageFactory(StorageFactory&&) =delete;
382- StorageFactory(StorageFactory const&) =delete;
383- StorageFactory& operator=(StorageFactory&&) =delete;
384- StorageFactory& operator=(StorageFactory const&) =delete;
385-
386- // TODO: is factory appropriate for this?
387- QFuture<QSharedPointer<Storage>> getStorage();
388-
389-private:
390-
391- // TODO: use the Qt pimpl macros
392- class Impl;
393- friend class Impl;
394- QSharedPointer<Impl> impl_;
395-};
396-
397-}
398
399=== removed file 'src/storage/storage.cpp'
400--- src/storage/storage.cpp 2016-06-20 15:23:27 +0000
401+++ src/storage/storage.cpp 1970-01-01 00:00:00 +0000
402@@ -1,36 +0,0 @@
403-/*
404- * Copyright (C) 2016 Canonical, Ltd.
405- *
406- * This program is free software: you can redistribute it and/or modify it
407- * under the terms of the GNU General Public License version 3, as published
408- * by the Free Software Foundation.
409- *
410- * This program is distributed in the hope that it will be useful, but
411- * WITHOUT ANY WARRANTY; without even the implied warranties of
412- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
413- * PURPOSE. See the GNU General Public License for more details.
414- *
415- * You should have received a copy of the GNU General Public License along
416- * with this program. If not, see <http://www.gnu.org/licenses/>.
417- *
418- * Authors:
419- * Charles Kerr <charles.kerr@canonical.com>
420- */
421-
422-#include "storage/storage.h"
423-
424-#include <QtDebug>
425-
426-namespace storage
427-{
428-
429-Storage::Storage()
430-{
431- qDebug() << "hello world";
432-}
433-
434-Storage::~Storage()
435-{
436-}
437-
438-} // namespace storage
439
440=== removed file 'src/storage/storage.h'
441--- src/storage/storage.h 2016-05-30 02:16:12 +0000
442+++ src/storage/storage.h 1970-01-01 00:00:00 +0000
443@@ -1,73 +0,0 @@
444-/*
445- * Copyright (C) 2016 Canonical, Ltd.
446- *
447- * This program is free software: you can redistribute it and/or modify it
448- * under the terms of the GNU General Public License version 3, as published
449- * by the Free Software Foundation.
450- *
451- * This program is distributed in the hope that it will be useful, but
452- * WITHOUT ANY WARRANTY; without even the implied warranties of
453- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
454- * PURPOSE. See the GNU General Public License for more details.
455- *
456- * You should have received a copy of the GNU General Public License along
457- * with this program. If not, see <http://www.gnu.org/licenses/>.
458- *
459- * Authors:
460- * Charles Kerr <charles.kerr@canonical.com>
461- */
462-
463-#pragma once
464-
465-#include <QDateTime>
466-#include <QIODevice>
467-#include <QSet>
468-#include <QSharedPointer>
469-#include <QString>
470-#include <QVariant>
471-#include <QVector>
472-
473-namespace storage
474-{
475-
476-// NB: this is an experimental class whose API should and will change
477-struct BackupInfo
478-{
479- QString uuid;
480-
481- // TODO: for 1.0 we only need multimedia and everything else; is a packages list needed?
482- QSet<QString> packages;
483- QDateTime timestamp;
484-
485- // TODO: this is an escape hatch for if we need to add more properties in the future.
486- // what are the use cases?
487- QVariantMap properties;
488-};
489-
490-// NB: this is an experimental class whose API should and will change
491-// TODO: other than these three functions, is there any other functionality to wrap around the storage framework?
492-// TODO: these three give Storage too much responsibility, eg startBackup means Storage needs to know how to launch helpers. We want a middleman to decouple them
493-class Storage
494-{
495-public:
496-
497- virtual ~Storage();
498-
499- Storage(Storage&&) =delete;
500- Storage(Storage const&) =delete;
501- Storage& operator=(Storage&&) =delete;
502- Storage& operator=(Storage const&) =delete;
503-
504- virtual QVector<BackupInfo> getBackups() =0;
505-
506- virtual QSharedPointer<QIODevice> startRestore(const QString& uuid) =0;
507-
508- // TODO: should Storage create the uuid itself?
509- virtual QSharedPointer<QIODevice> startBackup(const BackupInfo& info) =0;
510-
511-protected:
512-
513- Storage();
514-};
515-
516-}

Subscribers

People subscribed via source and target branches

to all changes: