]> _ Git - odl.git/commitdiff
Allows to download package file without regenerating zip
authorvincent <vincent@enhydra.fr>
Fri, 25 Mar 2022 18:07:16 +0000 (19:07 +0100)
committervincent <vincent@enhydra.fr>
Fri, 25 Mar 2022 18:07:16 +0000 (19:07 +0100)
app/Http/Controllers/Tools/PackageDownload.php
app/Http/Controllers/Tools/PackageDownloadFile.php [new file with mode: 0644]

index f06e99424a4dbe072a6758112ea2a47e4015e887..0c52b543139f8896d8df199b0220d0927e3100b9 100644 (file)
@@ -11,14 +11,7 @@ trait PackageDownload {
             return abort(403);
         }
         ProducePackage::dispatchSync();
-
-        $path = storage_path('package.zip');
-
-        if (file_exists($path)) {
-            return response(null)->header('Content-Disposition', 'attachment;filename=package.zip')->header('Content-Type', Files::_getMimeType($path))->header('X-Sendfile', $path);
-        } else {
-            return response(null)->setStatusCode(404);
-        }
+        return redirect(backpack_url('tools/packagedownloadfile'));
     }
 
 }
diff --git a/app/Http/Controllers/Tools/PackageDownloadFile.php b/app/Http/Controllers/Tools/PackageDownloadFile.php
new file mode 100644 (file)
index 0000000..dcd6c13
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Controllers\Tools;
+
+use App\Jobs\ProducePackage;
+
+trait PackageDownloadFile
+{
+    protected function packagedownload() {
+        if(!can('package')){
+            return abort(403);
+        }
+
+        $path = storage_path('package.zip');
+
+        if (file_exists($path)) {
+            return response(null)->header('Content-Disposition', 'attachment;filename=package.zip')->header('Content-Type', Files::_getMimeType($path))->header('X-Sendfile', $path);
+        } else {
+            return response(null)->setStatusCode(404);
+        }
+    }
+}