public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code
@ 2021-04-12 15:32 Stefan Reiter
  2021-04-12 15:32 ` [pve-devel] [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive Stefan Reiter
  2021-04-13  7:02 ` [pve-devel] applied: [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code Thomas Lamprecht
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Reiter @ 2021-04-12 15:32 UTC (permalink / raw)
  To: pve-devel, pbs-devel

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---

Smoke tested by downloading an entire container archive as zip, extracting and
checking the files. If there was a reason for this to be disabled let me know.

Based on my previous series to move the FileBrowser to the widget toolkit:
https://lists.proxmox.com/pipermail/pbs-devel/2021-April/002590.html

Depends on the proxmox-backup patch to work correctly.

 src/window/FileBrowser.js | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js
index d8e75f4..7d82b01 100644
--- a/src/window/FileBrowser.js
+++ b/src/window/FileBrowser.js
@@ -98,23 +98,7 @@ Ext.define("Proxmox.window.FileBrowser", {
 	    if (!selection || selection.length < 1) return;
 
 	    let data = selection[0].data;
-
-	    let canDownload = false;
-	    if (view.downloadUrl) {
-		switch (data.type) {
-		    case 'h':
-		    case 'f':
-			canDownload = true;
-			break;
-		    case 'd':
-			if (data.depth > 1) {
-			    canDownload = true;
-			}
-			break;
-		    default: break;
-		}
-	    }
-
+	    let canDownload = view.downloadUrl && ['h', 'f', 'd'].indexOf(data.type) !== -1;
 	    me.lookup('downloadBtn').setDisabled(!canDownload);
 	},
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive
  2021-04-12 15:32 [pve-devel] [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code Stefan Reiter
@ 2021-04-12 15:32 ` Stefan Reiter
  2021-04-13  6:39   ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht
  2021-04-13  7:02 ` [pve-devel] applied: [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code Thomas Lamprecht
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Reiter @ 2021-04-12 15:32 UTC (permalink / raw)
  To: pve-devel, pbs-devel

Treat filepaths like "/root.pxar.didx" without a trailing slash as
wanting to download the entire archive content instead of erroring. The
zip-creation code already works fine for this scenario.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
 src/api2/admin/datastore.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index a3e115f6..97860910 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -1385,7 +1385,7 @@ pub fn pxar_file_download(
 
         let mut split = components.splitn(2, |c| *c == b'/');
         let pxar_name = std::str::from_utf8(split.next().unwrap())?;
-        let file_path = split.next().ok_or_else(|| format_err!("filepath looks strange '{}'", filepath))?;
+        let file_path = split.next().unwrap_or(b"/");
         let (manifest, files) = read_backup_index(&datastore, &backup_dir)?;
         for file in files {
             if file.filename == pxar_name && file.crypt_mode == Some(CryptMode::Encrypt) {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] applied: [pbs-devel] [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive
  2021-04-12 15:32 ` [pve-devel] [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive Stefan Reiter
@ 2021-04-13  6:39   ` Thomas Lamprecht
  2021-04-13  7:23     ` [pve-devel] [pbs-devel] applied: " Dominik Csapak
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lamprecht @ 2021-04-13  6:39 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Stefan Reiter, pve-devel

On 12.04.21 17:32, Stefan Reiter wrote:
> Treat filepaths like "/root.pxar.didx" without a trailing slash as
> wanting to download the entire archive content instead of erroring. The
> zip-creation code already works fine for this scenario.
> 
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
> ---
>  src/api2/admin/datastore.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>

applied, thanks!

But that API is definitively weird in general...

1. old style API definition, should use the #[api()] macro instead
2. perly "params: Value", yeah, no thanks.
3. hard coded return stream type, one should be able to download also a single
   file as zip, and we knew that we wanted .tar then too, so not providing an
   param for that is weird.
4. accessed via /json/ path but never returns json





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] applied: [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code
  2021-04-12 15:32 [pve-devel] [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code Stefan Reiter
  2021-04-12 15:32 ` [pve-devel] [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive Stefan Reiter
@ 2021-04-13  7:02 ` Thomas Lamprecht
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2021-04-13  7:02 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stefan Reiter, pbs-devel

On 12.04.21 17:32, Stefan Reiter wrote:
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
> ---
> 
> Smoke tested by downloading an entire container archive as zip, extracting and
> checking the files. If there was a reason for this to be disabled let me know.
> 
> Based on my previous series to move the FileBrowser to the widget toolkit:
> https://lists.proxmox.com/pipermail/pbs-devel/2021-April/002590.html
> 
> Depends on the proxmox-backup patch to work correctly.
> 
>  src/window/FileBrowser.js | 18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)
> 
>

applied, thanks!

Added a actual config sections with comments for the widget specific params.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [pbs-devel] applied: [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive
  2021-04-13  6:39   ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht
@ 2021-04-13  7:23     ` Dominik Csapak
  2021-04-13  7:29       ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Csapak @ 2021-04-13  7:23 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Thomas Lamprecht,
	Stefan Reiter, pve-devel

On 4/13/21 08:39, Thomas Lamprecht wrote:
> On 12.04.21 17:32, Stefan Reiter wrote:
>> Treat filepaths like "/root.pxar.didx" without a trailing slash as
>> wanting to download the entire archive content instead of erroring. The
>> zip-creation code already works fine for this scenario.
>>
>> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
>> ---
>>   src/api2/admin/datastore.rs | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>
> 
> applied, thanks!
> 
> But that API is definitively weird in general...

just fyi

> 
> 1. old style API definition, should use the #[api()] macro instead

the api macro cannot handle AsyncHttp api calls (yet?), but this is 
required for the stream

> 2. perly "params: Value", yeah, no thanks.

a result from above, without api macro no de-structuring of parameters

> 3. hard coded return stream type, one should be able to download also a single
>     file as zip, and we knew that we wanted .tar then too, so not providing an
>     param for that is weird.

we always can add as much, but until now, generating a zip for a single
file was not really sensible

> 4. accessed via /json/ path but never returns json

all api calls need a formatter to call, should we add a
new one for download type?

> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [pbs-devel] applied: [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive
  2021-04-13  7:23     ` [pve-devel] [pbs-devel] applied: " Dominik Csapak
@ 2021-04-13  7:29       ` Thomas Lamprecht
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2021-04-13  7:29 UTC (permalink / raw)
  To: Dominik Csapak, Proxmox Backup Server development discussion,
	Stefan Reiter, pve-devel

On 13.04.21 09:23, Dominik Csapak wrote:
> On 4/13/21 08:39, Thomas Lamprecht wrote:
>> But that API is definitively weird in general...
> 
> just fyi
> 
>>
>> 1. old style API definition, should use the #[api()] macro instead
> 
> the api macro cannot handle AsyncHttp api calls (yet?), but this is required for the stream

that shoudn't be a hard problem, it's a macro it can expand to whatever..

>> 2. perly "params: Value", yeah, no thanks.
> 
> a result from above, without api macro no de-structuring of parameters

see above

> 
>> 3. hard coded return stream type, one should be able to download also a single
>>     file as zip, and we knew that we wanted .tar then too, so not providing an
>>     param for that is weird.
> 
> we always can add as much, but until now, generating a zip for a single
> file was not really sensible

Compression isn't the only benefit a encapsulation like an archive format.

> 
>> 4. accessed via /json/ path but never returns json
> 
> all api calls need a formatter to call, should we add a
> new one for download type?

I know that all paths have a formatter, does not validates misusing JSON
for something completely different ;)




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-13  7:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 15:32 [pve-devel] [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code Stefan Reiter
2021-04-12 15:32 ` [pve-devel] [PATCH proxmox-backup 2/2] api/datastore: allow pxar file download of entire archive Stefan Reiter
2021-04-13  6:39   ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht
2021-04-13  7:23     ` [pve-devel] [pbs-devel] applied: " Dominik Csapak
2021-04-13  7:29       ` Thomas Lamprecht
2021-04-13  7:02 ` [pve-devel] applied: [PATCH proxmox-widget-toolkit 1/2] FileBrowser: allow downloading root folder and simplify code Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal