Skip to content

Commit

Permalink
Merge pull request #8 from prsnbrg/v1.3.7
Browse files Browse the repository at this point in the history
Prepare release v1.3.7
  • Loading branch information
prsnbrg authored Mar 10, 2024
2 parents 97fcd90 + d56f787 commit f1d9628
Show file tree
Hide file tree
Showing 107 changed files with 51 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
appinfo/signature.json

.DS_Store
# Logs
logs
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## 1.3.7

- Improved performances
- Add logging

## 1.3.6

- NC27 support
Expand Down
Empty file modified COPYING
100644 → 100755
Empty file.
Empty file modified Makefile
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified appinfo/app.php
100644 → 100755
Empty file.
10 changes: 4 additions & 6 deletions appinfo/info.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<id>extract</id>
<name>Extract</name>
<summary>Extract archive from the web interface</summary>
<screenshot>https://raw.githubusercontent.com/PaulLereverend/NextcloudExtract/master/img/extract.png</screenshot>
<screenshot>https://raw.githubusercontent.com/prsnbrg/NextcloudExtract/master/img/extract.png</screenshot>
<description><![CDATA[Extract archives.
* **Supported :**
Expand All @@ -27,20 +27,18 @@
* p7zip (sudo apt-get install p7zip p7zip-full)
* **Note :** Encrypted files are not supported yet
* Fork from Nextcloud App extract
]]></description>

<version>1.3.6</version>
<version>1.3.7</version>
<licence>agpl</licence>
<author mail="[email protected]">Paul Lereverend</author>
<author>Paul Lereverend, Paul Rosenberg</author>
<namespace>Extract</namespace>
<category>files</category>
<category>tools</category>
<website>https://github.com/prsnbrg/NextcloudExtract</website>
<bugs>https://github.com/prsnbrg/NextcloudExtract/issues</bugs>
<dependencies>
<nextcloud min-version="20" max-version="27"/>
<owncloud min-version="10" max-version="10"/>
<owncloud min-version="10" max-version="10"/>
</dependencies>
</info>
Empty file modified appinfo/routes.php
100644 → 100755
Empty file.
Empty file modified composer.json
100644 → 100755
Empty file.
Empty file modified composer.lock
100644 → 100755
Empty file.
Empty file modified css/style.css
100644 → 100755
Empty file.
Empty file modified img/extract.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified img/extracticon.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified js/extraction.js
100644 → 100755
Empty file.
Empty file modified l10n/ar.js
100644 → 100755
Empty file.
Empty file modified l10n/ar.json
100644 → 100755
Empty file.
Empty file modified l10n/az.js
100644 → 100755
Empty file.
Empty file modified l10n/az.json
100644 → 100755
Empty file.
Empty file modified l10n/bg.js
100644 → 100755
Empty file.
Empty file modified l10n/bg.json
100644 → 100755
Empty file.
Empty file modified l10n/ca.js
100644 → 100755
Empty file.
Empty file modified l10n/ca.json
100644 → 100755
Empty file.
Empty file modified l10n/cs.js
100644 → 100755
Empty file.
Empty file modified l10n/cs.json
100644 → 100755
Empty file.
Empty file modified l10n/da.js
100644 → 100755
Empty file.
Empty file modified l10n/da.json
100644 → 100755
Empty file.
Empty file modified l10n/de.js
100644 → 100755
Empty file.
Empty file modified l10n/de.json
100644 → 100755
Empty file.
Empty file modified l10n/de_DE.js
100644 → 100755
Empty file.
Empty file modified l10n/de_DE.json
100644 → 100755
Empty file.
Empty file modified l10n/el.js
100644 → 100755
Empty file.
Empty file modified l10n/el.json
100644 → 100755
Empty file.
Empty file modified l10n/en_GB.js
100644 → 100755
Empty file.
Empty file modified l10n/en_GB.json
100644 → 100755
Empty file.
Empty file modified l10n/es.js
100644 → 100755
Empty file.
Empty file modified l10n/es.json
100644 → 100755
Empty file.
Empty file modified l10n/eu.js
100644 → 100755
Empty file.
Empty file modified l10n/eu.json
100644 → 100755
Empty file.
Empty file modified l10n/fa.js
100644 → 100755
Empty file.
Empty file modified l10n/fa.json
100644 → 100755
Empty file.
Empty file modified l10n/fi.js
100644 → 100755
Empty file.
Empty file modified l10n/fi.json
100644 → 100755
Empty file.
Empty file modified l10n/fr.js
100644 → 100755
Empty file.
Empty file modified l10n/fr.json
100644 → 100755
Empty file.
Empty file modified l10n/gl.js
100644 → 100755
Empty file.
Empty file modified l10n/gl.json
100644 → 100755
Empty file.
Empty file modified l10n/he.js
100644 → 100755
Empty file.
Empty file modified l10n/he.json
100644 → 100755
Empty file.
Empty file modified l10n/hr.js
100644 → 100755
Empty file.
Empty file modified l10n/hr.json
100644 → 100755
Empty file.
Empty file modified l10n/hu.js
100644 → 100755
Empty file.
Empty file modified l10n/hu.json
100644 → 100755
Empty file.
Empty file modified l10n/is.js
100644 → 100755
Empty file.
Empty file modified l10n/is.json
100644 → 100755
Empty file.
Empty file modified l10n/it.js
100644 → 100755
Empty file.
Empty file modified l10n/it.json
100644 → 100755
Empty file.
Empty file modified l10n/ja.js
100644 → 100755
Empty file.
Empty file modified l10n/ja.json
100644 → 100755
Empty file.
Empty file modified l10n/ko.js
100644 → 100755
Empty file.
Empty file modified l10n/ko.json
100644 → 100755
Empty file.
Empty file modified l10n/lt_LT.js
100644 → 100755
Empty file.
Empty file modified l10n/lt_LT.json
100644 → 100755
Empty file.
Empty file modified l10n/mk.js
100644 → 100755
Empty file.
Empty file modified l10n/mk.json
100644 → 100755
Empty file.
Empty file modified l10n/nb.js
100644 → 100755
Empty file.
Empty file modified l10n/nb.json
100644 → 100755
Empty file.
Empty file modified l10n/nl.js
100644 → 100755
Empty file.
Empty file modified l10n/nl.json
100644 → 100755
Empty file.
Empty file modified l10n/oc.js
100644 → 100755
Empty file.
Empty file modified l10n/oc.json
100644 → 100755
Empty file.
Empty file modified l10n/pl.js
100644 → 100755
Empty file.
Empty file modified l10n/pl.json
100644 → 100755
Empty file.
Empty file modified l10n/pt_BR.js
100644 → 100755
Empty file.
Empty file modified l10n/pt_BR.json
100644 → 100755
Empty file.
Empty file modified l10n/pt_PT.js
100644 → 100755
Empty file.
Empty file modified l10n/pt_PT.json
100644 → 100755
Empty file.
Empty file modified l10n/ru.js
100644 → 100755
Empty file.
Empty file modified l10n/ru.json
100644 → 100755
Empty file.
Empty file modified l10n/sc.js
100644 → 100755
Empty file.
Empty file modified l10n/sc.json
100644 → 100755
Empty file.
Empty file modified l10n/sk.js
100644 → 100755
Empty file.
Empty file modified l10n/sk.json
100644 → 100755
Empty file.
Empty file modified l10n/sl.js
100644 → 100755
Empty file.
Empty file modified l10n/sl.json
100644 → 100755
Empty file.
Empty file modified l10n/sr.js
100644 → 100755
Empty file.
Empty file modified l10n/sr.json
100644 → 100755
Empty file.
Empty file modified l10n/sv.js
100644 → 100755
Empty file.
Empty file modified l10n/sv.json
100644 → 100755
Empty file.
Empty file modified l10n/tr.js
100644 → 100755
Empty file.
Empty file modified l10n/tr.json
100644 → 100755
Empty file.
Empty file modified l10n/uk.js
100644 → 100755
Empty file.
Empty file modified l10n/uk.json
100644 → 100755
Empty file.
Empty file modified l10n/zh_CN.js
100644 → 100755
Empty file.
Empty file modified l10n/zh_CN.json
100644 → 100755
Empty file.
Empty file modified l10n/zh_HK.js
100644 → 100755
Empty file.
Empty file modified l10n/zh_HK.json
100644 → 100755
Empty file.
Empty file modified l10n/zh_TW.js
100644 → 100755
Empty file.
Empty file modified l10n/zh_TW.json
100644 → 100755
Empty file.
68 changes: 36 additions & 32 deletions lib/Controller/ExtractionController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
use OCP\Files\File;
use OCP\Files\Folder;

use OCP\IConfig;
use OCP\IL10N;
use OCP\Share\IManager;
use OCP\EventDispatcher\IEventDispatcher;

//use Psr\Log\LoggerInterface;
//use Psr\Log\LogLevel;
//use OCP\ILogger\LoggerInterface;
//use OCP\ILogger\LogLevel;
use \OCP\ILogger;

//use OCP\App\IAppManager;

Expand All @@ -35,7 +31,7 @@ class ExtractionController extends Controller {
private $l;

/** @var LoggerInterface */
// private $logger;
private $logger;

/** @var IRootFolder */
private $rootFolder;
Expand All @@ -55,13 +51,14 @@ public function __construct(
, ExtractionService $extractionService
, IRootFolder $rootFolder
, IL10N $l
// , LoggerInterface $logger
// , IManager $encryptionManager
, ILogger $logger
//, IManager $encryptionManager
, $UserId
){
parent::__construct($AppName, $request);
$this->l = $l;
// $this->logger = $logger;
$this->logger = $logger;
//$this->encryptionManager = $encryptionManager;
$this->userId = $UserId;
$this->extractionService = $extractionService;
$this->rootFolder = $rootFolder;
Expand Down Expand Up @@ -92,19 +89,19 @@ private function postExtract(string $fileName, string $directory, string $extrac
foreach ($iterator as $file) {
/** @var \SplFileInfo $file */
if (Filesystem::isFileBlacklisted($file->getBasename())) {
// $this->logger->warning(__METHOD__ . ': removing blacklisted file: ' . $file->getPathname());
$this->logger->warning(__METHOD__ . ': removing blacklisted file: ' . $file->getPathname());
// remove it
unlink($file->getPathname());
}
}

$NCDestination = $directory . '/' . $fileName;
if($tmpPath){
if($tmpPath != ""){
$tmpFolder = $this->rootFolder->get($tmpPath);
$tmpFolder->move($this->userFolder->getFullPath($NCDestination));
}else{
// This seems to be enough to trigger a files-cache refresh
$this->userFolder->get($NCDestination);
$scanner = new \OC\Files\Utils\Scanner($this->userId, \OC::$server->getDatabaseConnection(), \OC::$server->getLogger());
$scanner->scan($this->userFolder->getFullPath($NCDestination));
}
}

Expand All @@ -114,6 +111,7 @@ private function postExtract(string $fileName, string $directory, string $extrac
* @NoAdminRequired
*/
public function extract($nameOfFile, $directory, $external, $type){
$this->logger->warning(\OC::$server->getEncryptionManager()->isEnabled());
if (\OC::$server->getEncryptionManager()->isEnabled()) {
$response = array();
$response = array_merge($response, array("code" => 0, "desc" => $this->l->t("Encryption is not supported yet")));
Expand All @@ -125,28 +123,34 @@ public function extract($nameOfFile, $directory, $external, $type){
$fileName = pathinfo($nameOfFile, PATHINFO_FILENAME);
$extractTo = $dir . '/' . $fileName;

$appPath = $this->userId . '/' . $this->appName;
try {
$appDirectory = $this->rootFolder->get($appPath);
} catch (\OCP\Files\NotFoundException $e) {
$appDirectory = $this->rootFolder->newFolder($appPath);
}
if(pathinfo($fileName, PATHINFO_EXTENSION) == "tar"){
$archiveDir = pathinfo($fileName, PATHINFO_FILENAME);
} else {
$archiveDir = $fileName;
}
// if the file is un external storage
if($external){

// remove temporary directory if exists from interrupted previous runs
try {
$appDirectory->get($archiveDir)->delete();
} catch (\OCP\Files\NotFoundException $e) {
// ok
}
$appPath = $this->userId . '/' . $this->appName;
try {
$appDirectory = $this->rootFolder->get($appPath);
} catch (\OCP\Files\NotFoundException $e) {
$appDirectory = $this->rootFolder->newFolder($appPath);
}
if(pathinfo($fileName, PATHINFO_EXTENSION) == "tar"){
$archiveDir = pathinfo($fileName, PATHINFO_FILENAME);
} else {
$archiveDir = $fileName;
}

$tmpPath = $appDirectory->getPath() . '/' . $archiveDir;
$extractTo = $appDirectory->getStorage()->getLocalFile($appDirectory->getInternalPath()) . '/' . $archiveDir;
// remove temporary directory if exists from interrupted previous runs
try {
$appDirectory->get($archiveDir)->delete();
} catch (\OCP\Files\NotFoundException $e) {
// ok
}

$tmpPath = $appDirectory->getPath() . '/' . $archiveDir;
$extractTo = $appDirectory->getStorage()->getLocalFile($appDirectory->getInternalPath()) . '/' . $archiveDir;
} else {
$tmpPath = "";
}

switch ($type) {
case 'zip':
$response = $this->extractionService->extractZip($file, $fileName, $extractTo);
Expand Down
9 changes: 4 additions & 5 deletions lib/Service/ExtractionService.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

namespace OCA\Extract\Service;

//use Psr\Log\LoggerInterface;
//use Psr\Log\LogLevel;
use \OCP\ILogger;
use OCP\IL10N;

use ZipArchive;
Expand All @@ -39,10 +38,10 @@ class ExtractionService {

public function __construct(
IL10N $l
// , LoggerInterface $logger
, ILogger $logger
) {
$this->l = $l;
// $this->logger = $logger;
$this->logger = $logger;
}

public function extractZip($file, $filename, $extractTo){
Expand Down Expand Up @@ -96,7 +95,7 @@ public function extractOther($file, $filename, $extractTo){

if(sizeof($output) <= 5){
$response = array_merge($response, array("code" => 0, "desc" => $this->l->t("Oops something went wrong. Check that you have p7zip installed")));
// $this->logger->log(LogLevel::ERROR, __METHOD__ . ': ' . $output);
$this->logger->error(__METHOD__ . ': ' . $output);
return $response;
}
$response = array_merge($response, array("code" => 1));
Expand Down
Empty file modified phpunit.integration.xml
100644 → 100755
Empty file.
Empty file modified phpunit.xml
100644 → 100755
Empty file.
Empty file modified templates/content/index.php
100644 → 100755
Empty file.
Empty file modified templates/settings/index.php
100644 → 100755
Empty file.
Empty file modified tests/Integration/AppTest.php
100644 → 100755
Empty file.
Empty file modified tests/Unit/Controller/PageControllerTest.php
100644 → 100755
Empty file.
Empty file modified tests/bootstrap.php
100644 → 100755
Empty file.

0 comments on commit f1d9628

Please sign in to comment.