Merge lp:~charlesk/keeper/keeper-tar-create-require-zero-delimited-files into lp:keeper

Proposed by Charles Kerr
Status: Merged
Merge reported by: Charles Kerr
Merged at revision: not available
Proposed branch: lp:~charlesk/keeper/keeper-tar-create-require-zero-delimited-files
Merge into: lp:keeper
Prerequisite: lp:~charlesk/keeper/keeper-tar-create-handle-libarchive-failure-gracefully
Diff against target: 138 lines (+13/-43)
5 files modified
src/tar/main.cpp (+9/-39)
tests/fakes/helper-test.sh.in (+1/-1)
tests/unit/tar/ktc-invoke-nobus.sh.in (+1/-1)
tests/unit/tar/ktc-invoke-nofiles.sh.in (+1/-1)
tests/unit/tar/ktc-invoke.sh.in (+1/-1)
To merge this branch: bzr merge lp:~charlesk/keeper/keeper-tar-create-require-zero-delimited-files
Reviewer Review Type Date Requested Status
Xavi Garcia (community) Approve
Review via email: mp+301946@code.launchpad.net

Commit message

Remove the '-0' option from keeper-tar-create because it should be required, not optional.

Description of the change

An easy review this time: remove the '-0' option from keeper-tar-create because it should be required, not optional.

This also lets us remove the shell globbing code from keeper-tar-create as it's no longer needed.

To post a comment you must log in.
79. By Charles Kerr

in keeper-tar-create's usage string, fix typo

Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/tar/main.cpp'
2--- src/tar/main.cpp 2016-08-03 18:58:12 +0000
3+++ src/tar/main.cpp 2016-08-03 18:58:12 +0000
4@@ -30,8 +30,6 @@
5 #include <QFile>
6 #include <QLocalSocket>
7
8-#include <glib.h>
9-
10 #include <sys/select.h>
11 #include <unistd.h>
12
13@@ -44,7 +42,7 @@
14 {
15
16 QStringList
17-get_filenames_from_file(FILE * fp, bool zero)
18+get_filenames_from_file(FILE * fp)
19 {
20 // don't wait forever...
21 int fd = fileno(fp);
22@@ -65,29 +63,9 @@
23 auto filenames_raw = file.readAll();
24 file.close();
25
26- QList<QByteArray> tokens;
27- if (zero)
28- {
29- tokens = filenames_raw.split('\0');
30- }
31- else
32- {
33- // can't find a Qt equivalent of g_shell_parse_argv()...
34- gchar** filenames_strv {};
35- GError* err {};
36- filenames_raw = QString(filenames_raw).toUtf8(); // ensure a trailing '\0'
37- g_shell_parse_argv(filenames_raw.constData(), nullptr, &filenames_strv, &err);
38- if (err != nullptr)
39- g_warning("Unable to parse file list: %s", err->message);
40- for(int i=0; filenames_strv && filenames_strv[i]; ++i)
41- tokens.append(QByteArray(filenames_strv[i]));
42- g_clear_pointer(&filenames_strv, g_strfreev);
43- g_clear_error(&err);
44- }
45-
46 // massage into a QStringList
47 QStringList filenames;
48- for (const auto& token : tokens)
49+ for (const auto& token : filenames_raw.split('\0'))
50 if (!token.isEmpty())
51 filenames.append(QString::fromUtf8(token));
52
53@@ -102,28 +80,21 @@
54 parser.addHelpOption();
55 parser.setApplicationDescription(
56 "\n"
57- "Reads filenames from the standard input, delimited either by blanks (which can\n"
58- "be protected with double or single quotes or a backslash), builds an in-memory\n"
59- "archive of those files, and sends them to the Keeper service to store remotely.\n"
60+ "Reads filenames from the standard input, delimited either by a null character,\n"
61+ "builds an in-memory archive of those files, and sends them to the Keeper service\n"
62+ " to store remotely.\n"
63 "\n"
64- "Because Unix filenames can contain blanks and newlines, it is generally better\n"
65- "to use the -0 option, which prevents such problems. When using this option you\n"
66- "will need to ensure the program which produces input also uses a null character\n"
67- "a separator. If that program is GNU find, for example, the -print0 option does\n"
68+ "You will need to insure that the program which produces input uses a null character\n"
69+ "as a separator. If that program is GNU find, for example, the -print0 option does\n"
70 "this for you.\n"
71 "\n"
72- "Helper usage: find /your/data/path -print0 | " APP_NAME " -0 -a /bus/path"
73+ "Helper usage: find /your/data/path -print0 | " APP_NAME " -a /bus/path"
74 );
75 QCommandLineOption compress_option{
76 QStringList() << "c" << "compress",
77 QStringLiteral("Compress files before adding to archive")
78 };
79 parser.addOption(compress_option);
80- QCommandLineOption zero_delimiter_option{
81- QStringList() << "0" << "null",
82- QStringLiteral("Input items are terminated by a null character instead of by whitespace")
83- };
84- parser.addOption(zero_delimiter_option);
85 QCommandLineOption bus_path_option{
86 QStringList() << "a" << "bus-path",
87 QStringLiteral("Keeper service's DBus path"),
88@@ -132,7 +103,6 @@
89 parser.addOption(bus_path_option);
90 parser.process(app);
91 const bool compress = parser.isSet(compress_option);
92- const bool zero = parser.isSet(zero_delimiter_option);
93 const auto bus_path = parser.value(bus_path_option);
94
95 // gotta have the bus path
96@@ -142,7 +112,7 @@
97 }
98
99 // gotta have files
100- const auto filenames = get_filenames_from_file(stdin, zero);
101+ const auto filenames = get_filenames_from_file(stdin);
102 for (const auto& filename : filenames)
103 qDebug() << "filename: " << filename;
104 if (filenames.empty()) {
105
106=== modified file 'tests/fakes/helper-test.sh.in'
107--- tests/fakes/helper-test.sh.in 2016-07-29 14:20:23 +0000
108+++ tests/fakes/helper-test.sh.in 2016-08-03 18:58:12 +0000
109@@ -19,5 +19,5 @@
110 #
111
112 echo $PWD >> /tmp/helper-pwd
113-find ./ -type f -print0 | @KEEPER_TAR_CREATE_BIN@ -0 -a /com/canonical/keeper/helper
114+find ./ -type f -print0 | @KEEPER_TAR_CREATE_BIN@ -a /com/canonical/keeper/helper
115 touch /tmp/simple-helper-finished
116
117=== modified file 'tests/unit/tar/ktc-invoke-nobus.sh.in'
118--- tests/unit/tar/ktc-invoke-nobus.sh.in 2016-08-03 18:58:12 +0000
119+++ tests/unit/tar/ktc-invoke-nobus.sh.in 2016-08-03 18:58:12 +0000
120@@ -1,2 +1,2 @@
121 find ./ -type f
122-find ./ -type f -print0 | @KEEPER_TAR_CREATE_BIN@ -0
123+find ./ -type f -print0 | @KEEPER_TAR_CREATE_BIN@
124
125=== modified file 'tests/unit/tar/ktc-invoke-nofiles.sh.in'
126--- tests/unit/tar/ktc-invoke-nofiles.sh.in 2016-08-03 18:58:12 +0000
127+++ tests/unit/tar/ktc-invoke-nofiles.sh.in 2016-08-03 18:58:12 +0000
128@@ -1,1 +1,1 @@
129-@KEEPER_TAR_CREATE_BIN@ -0 -a /com/canonical/keeper/helper
130+@KEEPER_TAR_CREATE_BIN@ -a /com/canonical/keeper/helper
131
132=== modified file 'tests/unit/tar/ktc-invoke.sh.in'
133--- tests/unit/tar/ktc-invoke.sh.in 2016-07-22 13:49:34 +0000
134+++ tests/unit/tar/ktc-invoke.sh.in 2016-08-03 18:58:12 +0000
135@@ -1,2 +1,2 @@
136 find ./ -type f
137-find ./ -type f -print0 | @KEEPER_TAR_CREATE_BIN@ -0 -a /com/canonical/keeper/helper
138+find ./ -type f -print0 | @KEEPER_TAR_CREATE_BIN@ -a /com/canonical/keeper/helper

Subscribers

People subscribed via source and target branches

to all changes: