mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
PHRAS-3958_download-one-asset (#4425)
* fix sync-download 1 doc ; fix stamp not removed * remove test
This commit is contained in:
@@ -9,14 +9,12 @@
|
|||||||
*/
|
*/
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
|
||||||
use Alchemy\Phrasea\Application\Helper\DelivererAware;
|
use Alchemy\Phrasea\Application\Helper\DelivererAware;
|
||||||
use Alchemy\Phrasea\Application\Helper\DispatcherAware;
|
use Alchemy\Phrasea\Application\Helper\DispatcherAware;
|
||||||
use Alchemy\Phrasea\Application\Helper\FilesystemAware;
|
use Alchemy\Phrasea\Application\Helper\FilesystemAware;
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\Http\DeliverDataInterface;
|
use Alchemy\Phrasea\Http\DeliverDataInterface;
|
||||||
use Alchemy\Phrasea\Model\Entities\Token;
|
use Alchemy\Phrasea\Model\Entities\Token;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
@@ -107,17 +105,17 @@ class DoDownloadController extends Controller
|
|||||||
|
|
||||||
$exportName = $list['export_name'];
|
$exportName = $list['export_name'];
|
||||||
|
|
||||||
if ($list['count'] === 1 && !$list['cgu']) {
|
// if ($list['count'] === 1 && !$list['cgu']) {
|
||||||
$file = end($list['files']);
|
// $file = end($list['files']);
|
||||||
$subdef = end($file['subdefs']);
|
// $subdef = end($file['subdefs']);
|
||||||
$exportName = sprintf('%s%s.%s', $file['export_name'], $subdef['ajout'], $subdef['exportExt']);
|
// $exportName = sprintf('%s%s.%s', $file['export_name'], $subdef['ajout'], $subdef['exportExt']);
|
||||||
$exportFile = \p4string::addEndSlash($subdef['path']) . $subdef['file'];
|
// $exportFile = \p4string::addEndSlash($subdef['path']) . $subdef['file'];
|
||||||
$mime = $subdef['mime'];
|
// $mime = $subdef['mime'];
|
||||||
$list['complete'] = true;
|
// $list['complete'] = true;
|
||||||
} else {
|
// } else {
|
||||||
$exportFile = $this->app['tmp.download.path'].'/'.$token->getValue() . '.zip';
|
$exportFile = $this->app['tmp.download.path'].'/'.$token->getValue() . '.zip';
|
||||||
$mime = 'application/zip';
|
$mime = 'application/zip';
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!$this->getFilesystem()->exists($exportFile)) {
|
if (!$this->getFilesystem()->exists($exportFile)) {
|
||||||
$this->app->abort(404, 'Download file not found');
|
$this->app->abort(404, 'Download file not found');
|
||||||
@@ -159,21 +157,21 @@ class DoDownloadController extends Controller
|
|||||||
$session->save();
|
$session->save();
|
||||||
ignore_user_abort(true);
|
ignore_user_abort(true);
|
||||||
|
|
||||||
if ($list['count'] > 1) {
|
// if ($list['count'] > 1 || $list['cgu']) {
|
||||||
\set_export::build_zip(
|
\set_export::build_zip(
|
||||||
$this->app,
|
$this->app,
|
||||||
$token,
|
$token,
|
||||||
$list,
|
$list,
|
||||||
sprintf('%s/%s.zip', $this->app['tmp.download.path'], $token->getValue()) // Dest file
|
sprintf('%s/%s.zip', $this->app['tmp.download.path'], $token->getValue()) // Dest file
|
||||||
);
|
);
|
||||||
} else {
|
// } else {
|
||||||
$list['complete'] = true;
|
// $list['complete'] = true;
|
||||||
$token->setData(serialize($list));
|
// $token->setData(serialize($list));
|
||||||
/** @var EntityManagerInterface $manager */
|
// /** @var EntityManagerInterface $manager */
|
||||||
$manager = $this->app['orm.em'];
|
// $manager = $this->app['orm.em'];
|
||||||
$manager->persist($token);
|
// $manager->persist($token);
|
||||||
$manager->flush();
|
// $manager->flush();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return $this->app->json([
|
return $this->app->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@@ -17,6 +17,7 @@ use Alchemy\Phrasea\Core\Event\ExportEvent;
|
|||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Filesystem\PhraseanetFilesystem;
|
use Alchemy\Phrasea\Filesystem\PhraseanetFilesystem;
|
||||||
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
|
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
|
||||||
|
use Exception;
|
||||||
use set_export;
|
use set_export;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
@@ -81,6 +82,7 @@ class DownloadController extends Controller
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function listDownloadAsync(Request $request)
|
public function listDownloadAsync(Request $request)
|
||||||
{
|
{
|
||||||
@@ -98,12 +100,6 @@ class DownloadController extends Controller
|
|||||||
$this->app->abort(403);
|
$this->app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "stamp_choice" is a ckbox with value "NO_STAMP" to "remove stamp" on download
|
|
||||||
$stamp_method = set_export::STAMP_ASYNC; // will not stamp, but flag files to be stamped
|
|
||||||
if($request->request->get('stamp_choice') === set_export::NO_STAMP) {
|
|
||||||
$stamp_method = set_export::NO_STAMP;
|
|
||||||
}
|
|
||||||
|
|
||||||
$list = $download->prepare_export(
|
$list = $download->prepare_export(
|
||||||
$this->getAuthenticatedUser(),
|
$this->getAuthenticatedUser(),
|
||||||
$this->getFilesystem(),
|
$this->getFilesystem(),
|
||||||
@@ -128,7 +124,7 @@ class DownloadController extends Controller
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$record = new \record_adapter($this->app, $sbasId, $file['record_id']);
|
$record = new \record_adapter($this->app, $sbasId, $file['record_id']);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +179,10 @@ class DownloadController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new \Exception("invalid or expired token");
|
throw new Exception("invalid or expired token");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(\Exception $e) {
|
catch(Exception $e) {
|
||||||
// no-op
|
// no-op
|
||||||
$this->app->abort(403, $e->getMessage());
|
$this->app->abort(403, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
@@ -173,7 +173,7 @@
|
|||||||
{% if removeable_stamp and download.has_stamp_option() == true %}
|
{% if removeable_stamp and download.has_stamp_option() == true %}
|
||||||
<div id="stamp_choice" class="well-small" style="margin-left: 20px;" >
|
<div id="stamp_choice" class="well-small" style="margin-left: 20px;" >
|
||||||
<label for="option_stamp" class="checkbox">
|
<label for="option_stamp" class="checkbox">
|
||||||
<input class="stamp_choice" type="checkbox" id="stamp_choice" name="stamp_choice" value="NO_STAMP" />
|
<input class="stamp_choice" type="checkbox" id="stamp_choice" name="stamp_choice" value="REMOVE_STAMP" />
|
||||||
{{ 'prod::download: delete-marking-stamp' | trans }}
|
{{ 'prod::download: delete-marking-stamp' | trans }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -79,6 +79,9 @@ class DoDownloadTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testOneDocumentsDownload()
|
public function testOneDocumentsDownload()
|
||||||
{
|
{
|
||||||
|
$this->markTestSkipped("direct download removed by PHRAS-3958");
|
||||||
|
|
||||||
|
/*
|
||||||
$nbRowLogsBefore = $this->getNbRowLogs(self::$DI['record_1']->get_databox());
|
$nbRowLogsBefore = $this->getNbRowLogs(self::$DI['record_1']->get_databox());
|
||||||
$thumbnail = self::$DI['record_1']->get_thumbnail();
|
$thumbnail = self::$DI['record_1']->get_thumbnail();
|
||||||
|
|
||||||
@@ -119,6 +122,7 @@ class DoDownloadTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$nbRowLogsAfter = $this->getNbRowLogs(self::$DI['record_1']->get_databox());
|
$nbRowLogsAfter = $this->getNbRowLogs(self::$DI['record_1']->get_databox());
|
||||||
$this->assertGreaterThan($nbRowLogsBefore, $nbRowLogsAfter);
|
$this->assertGreaterThan($nbRowLogsBefore, $nbRowLogsAfter);
|
||||||
unset($response);
|
unset($response);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments
|
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments
|
||||||
|
Reference in New Issue
Block a user