Merge lp:~nikwen/ubuntu-filemanager-app/compressed-tars into lp:ubuntu-filemanager-app

Proposed by Niklas Wenzel
Status: Merged
Approved by: Niklas Wenzel
Approved revision: 373
Merged at revision: 385
Proposed branch: lp:~nikwen/ubuntu-filemanager-app/compressed-tars
Merge into: lp:ubuntu-filemanager-app
Diff against target: 124 lines (+58/-1)
4 files modified
src/app/qml/ui/FolderListPage.qml (+22/-1)
src/plugin/archives/archives.cpp (+18/-0)
src/plugin/archives/archives.h (+2/-0)
tests/autopilot/filemanager/tests/test_filemanager.py (+16/-0)
To merge this branch: bzr merge lp:~nikwen/ubuntu-filemanager-app/compressed-tars
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Arto Jalkanen Approve
Review via email: mp+249250@code.launchpad.net

Commit message

Added support for compressed tar archive extraction

Thanks to Carla Sella for fixing the failing autopilot tests before I even had the chance to look at the results. :)

Description of the change

Added support for compressed tar archive extraction

To post a comment you must log in.
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Let's see whether the autopilot test changes work. :D

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I'll just note tests in trunk do pass:

http://91.189.93.70:8080/job/ubuntu-filemanager-app-ci/453/

That said, there might need to be some changes made to tests in trunk.

Revision history for this message
Carla Sella (carla-sella) wrote :

I found the problem, the tar.bz2 and tar.gz files in the content directory are wrong, the content must be the same as the .tar and .zip ones otherwise the tests fail.
I tried to push my changes, but I do not have permission.

Revision history for this message
Carla Sella (carla-sella) wrote :
Revision history for this message
Carla Sella (carla-sella) wrote :
Revision history for this message
Carla Sella (carla-sella) wrote :
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Just give me some time to look into it myself! :D :p

You're right, of course. I got the command for producing the archives wrong. Embarassing!

I'll happily merge your changes. ;)

Revision history for this message
Carla Sella (carla-sella) wrote :

:-) no worries, four eyes are better than two ;).

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Let's wait for someone to review it now. Thanks again. ;)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Looks good to me.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

This looks like an error with resolving dependencies in the chroot.
I'll push a no-change commit to trigger automatic tests again.

373. By Niklas Wenzel

No-change commit to trigger autopilot tests again

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

So it worked this time. :)
Since I haven't changed anything since Arto's approval, I'll do a top-level approval myself now. Thank you to all who were involved. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/ui/FolderListPage.qml'
2--- src/app/qml/ui/FolderListPage.qml 2015-01-06 23:24:33 +0000
3+++ src/app/qml/ui/FolderListPage.qml 2015-02-22 10:24:24 +0000
4@@ -383,11 +383,28 @@
5
6 function getArchiveType(fileName) {
7 var splitName = fileName.split(".")
8+
9+ if (splitName.length <= 1) { // To sort out files simply named "zip" or "tar"
10+ return ""
11+ }
12+
13 var fileExtension = splitName[splitName.length - 1]
14 if (fileExtension === "zip") {
15 return "zip"
16 } else if (fileExtension === "tar") {
17 return "tar"
18+ } else if (fileExtension === "gz") {
19+ if (splitName.length > 2 && splitName[splitName.length - 2] === "tar") {
20+ return "tar.gz"
21+ } else {
22+ return ""
23+ }
24+ } else if (fileExtension === "bz2") {
25+ if (splitName.length > 2 && splitName[splitName.length - 2] === "tar") {
26+ return "tar.bz2"
27+ } else {
28+ return ""
29+ }
30 } else {
31 return ""
32 }
33@@ -938,7 +955,7 @@
34 console.log("Extracting...")
35
36 var parentDirectory = filePath.substring(0, filePath.lastIndexOf("/"))
37- var fileNameWithoutExtension = fileName.substring(0, fileName.lastIndexOf("."))
38+ var fileNameWithoutExtension = fileName.substring(0, fileName.lastIndexOf(archiveType) - 1)
39 var extractDirectory = parentDirectory + "/" + fileNameWithoutExtension
40
41 // Add numbers if the directory already exist: myfile, myfile-1, myfile-2, etc.
42@@ -960,6 +977,10 @@
43 archives.extractZip(filePath, extractDirectory)
44 } else if (archiveType === "tar") {
45 archives.extractTar(filePath, extractDirectory)
46+ } else if (archiveType === "tar.gz") {
47+ archives.extractGzipTar(filePath, extractDirectory)
48+ } else if (archiveType === "tar.bz2") {
49+ archives.extractBzipTar(filePath, extractDirectory)
50 }
51 }
52
53
54=== modified file 'src/plugin/archives/archives.cpp'
55--- src/plugin/archives/archives.cpp 2014-12-26 10:44:19 +0000
56+++ src/plugin/archives/archives.cpp 2015-02-22 10:24:24 +0000
57@@ -37,6 +37,24 @@
58 extractArchive(program, arguments);
59 }
60
61+void Archives::extractGzipTar(const QString path, const QString destination)
62+{
63+ QString program = "tar";
64+ QStringList arguments;
65+ arguments << "xzf" << path << "-C" << destination;
66+
67+ extractArchive(program, arguments);
68+}
69+
70+void Archives::extractBzipTar(const QString path, const QString destination)
71+{
72+ QString program = "tar";
73+ QStringList arguments;
74+ arguments << "xjf" << path << "-C" << destination;
75+
76+ extractArchive(program, arguments);
77+}
78+
79 void Archives::extractArchive(const QString program, const QStringList arguments)
80 {
81 if (_process != nullptr && _process->state() == QProcess::ProcessState::Running) {
82
83=== modified file 'src/plugin/archives/archives.h'
84--- src/plugin/archives/archives.h 2014-12-26 10:44:19 +0000
85+++ src/plugin/archives/archives.h 2015-02-22 10:24:24 +0000
86@@ -29,6 +29,8 @@
87 public:
88 Q_INVOKABLE void extractZip(const QString path, const QString destination);
89 Q_INVOKABLE void extractTar(const QString path, const QString destination);
90+ Q_INVOKABLE void extractGzipTar(const QString path, const QString destination);
91+ Q_INVOKABLE void extractBzipTar(const QString path, const QString destination);
92 Q_INVOKABLE void cancelArchiveExtraction();
93
94 signals:
95
96=== added file 'tests/autopilot/filemanager/content/Test.tar.bz2'
97Binary files tests/autopilot/filemanager/content/Test.tar.bz2 1970-01-01 00:00:00 +0000 and tests/autopilot/filemanager/content/Test.tar.bz2 2015-02-22 10:24:24 +0000 differ
98=== added file 'tests/autopilot/filemanager/content/Test.tar.gz'
99Binary files tests/autopilot/filemanager/content/Test.tar.gz 1970-01-01 00:00:00 +0000 and tests/autopilot/filemanager/content/Test.tar.gz 2015-02-22 10:24:24 +0000 differ
100=== modified file 'tests/autopilot/filemanager/tests/test_filemanager.py'
101--- tests/autopilot/filemanager/tests/test_filemanager.py 2014-12-11 20:16:40 +0000
102+++ tests/autopilot/filemanager/tests/test_filemanager.py 2015-02-22 10:24:24 +0000
103@@ -50,6 +50,22 @@
104 'extracted_text_file_name': 'CodeOfConduct.txt',
105 'extracted_image_dir_name': 'images',
106 'extracted_image_name': 'ubuntu.jpg'
107+ }),
108+
109+ ('tar_gz',
110+ {'file_to_extract': 'Test.tar.gz',
111+ 'extracted_dir_name': 'Test',
112+ 'extracted_text_file_name': 'CodeOfConduct.txt',
113+ 'extracted_image_dir_name': 'images',
114+ 'extracted_image_name': 'ubuntu.jpg'
115+ }),
116+
117+ ('tar_bz2',
118+ {'file_to_extract': 'Test.tar.bz2',
119+ 'extracted_dir_name': 'Test',
120+ 'extracted_text_file_name': 'CodeOfConduct.txt',
121+ 'extracted_image_dir_name': 'images',
122+ 'extracted_image_name': 'ubuntu.jpg'
123 })
124 ]
125

Subscribers

People subscribed via source and target branches