* [pve-devel] [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes
@ 2021-07-01 7:53 Fabian Ebner
2021-07-01 7:53 ` [pve-devel] [PATCH proxmox-widget-toolkit 1/1] apt repos: use correct URL Fabian Ebner
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Fabian Ebner @ 2021-07-01 7:53 UTC (permalink / raw)
To: pve-devel
proxmox-widget-toolkit:
Fabian Ebner (1):
apt repos: use correct URL
src/node/APTRepositories.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
pve-rs:
Fabian Ebner (1):
apt: avoid overwriting files that could not be parsed
src/apt/repositories.rs | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH proxmox-widget-toolkit 1/1] apt repos: use correct URL
2021-07-01 7:53 [pve-devel] [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Fabian Ebner
@ 2021-07-01 7:53 ` Fabian Ebner
2021-07-01 7:54 ` [pve-devel] [PATCH pve-rs 1/1] apt: avoid overwriting files that could not be parsed Fabian Ebner
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Fabian Ebner @ 2021-07-01 7:53 UTC (permalink / raw)
To: pve-devel
so there is a 'result' property, which the window expects.
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
src/node/APTRepositories.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js
index baca834..53ffc1a 100644
--- a/src/node/APTRepositories.js
+++ b/src/node/APTRepositories.js
@@ -167,7 +167,7 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
Ext.create('Proxmox.window.APTRepositoryAdd', {
repoInfo: me.repoInfo,
- url: `/api2/json/nodes/${panel.nodename}/apt/repositories`,
+ url: `/api2/extjs/nodes/${panel.nodename}/apt/repositories`,
method: 'PUT',
extraRequestParams: extraParams,
listeners: {
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-rs 1/1] apt: avoid overwriting files that could not be parsed
2021-07-01 7:53 [pve-devel] [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Fabian Ebner
2021-07-01 7:53 ` [pve-devel] [PATCH proxmox-widget-toolkit 1/1] apt repos: use correct URL Fabian Ebner
@ 2021-07-01 7:54 ` Fabian Ebner
2021-07-01 9:01 ` [pve-devel] [PATCH pve-rs] apt: check if repository is already configured before adding Fabian Ebner
2021-07-02 11:03 ` [pve-devel] applied-series: [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Fabian Ebner @ 2021-07-01 7:54 UTC (permalink / raw)
To: pve-devel
The enable/disable case should not be reachable via UI as the digest
check comes first, but it's still good to fix it too.
Reported-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
src/apt/repositories.rs | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/apt/repositories.rs b/src/apt/repositories.rs
index 3a421f0..26af67c 100644
--- a/src/apt/repositories.rs
+++ b/src/apt/repositories.rs
@@ -60,7 +60,7 @@ mod export {
/// The `digest` parameter asserts that the configuration has not been modified.
#[export]
pub fn add_repository(handle: &str, digest: Option<&str>) -> Result<(), Error> {
- let (mut files, _errors, current_digest) = proxmox_apt::repositories::repositories()?;
+ let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?;
if let Some(digest) = digest {
let expected_digest = proxmox::tools::hex_to_digest(digest)?;
@@ -72,6 +72,14 @@ mod export {
let (repo, path) =
proxmox_apt::repositories::get_standard_repository(handle.try_into()?, "pve")?;
+ if let Some(error) = errors.iter().find(|error| error.path == path) {
+ bail!(
+ "unable to parse existing file {} - {}",
+ error.path,
+ error.error,
+ );
+ }
+
if let Some(file) = files.iter_mut().find(|file| file.path == path) {
file.repositories.push(repo);
@@ -100,7 +108,7 @@ mod export {
options: ChangeProperties,
digest: Option<&str>,
) -> Result<(), Error> {
- let (mut files, _errors, current_digest) = proxmox_apt::repositories::repositories()?;
+ let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?;
if let Some(digest) = digest {
let expected_digest = proxmox::tools::hex_to_digest(digest)?;
@@ -109,6 +117,10 @@ mod export {
}
}
+ if let Some(error) = errors.iter().find(|error| error.path == path) {
+ bail!("unable to parse file {} - {}", error.path, error.error);
+ }
+
if let Some(file) = files.iter_mut().find(|file| file.path == path) {
if let Some(repo) = file.repositories.get_mut(index) {
if let Some(enabled) = options.enabled {
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-rs] apt: check if repository is already configured before adding
2021-07-01 7:53 [pve-devel] [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Fabian Ebner
2021-07-01 7:53 ` [pve-devel] [PATCH proxmox-widget-toolkit 1/1] apt repos: use correct URL Fabian Ebner
2021-07-01 7:54 ` [pve-devel] [PATCH pve-rs 1/1] apt: avoid overwriting files that could not be parsed Fabian Ebner
@ 2021-07-01 9:01 ` Fabian Ebner
2021-07-02 11:03 ` [pve-devel] applied-series: [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Fabian Ebner @ 2021-07-01 9:01 UTC (permalink / raw)
To: pve-devel
and if it is, enable it.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
src/apt/repositories.rs | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/apt/repositories.rs b/src/apt/repositories.rs
index 26af67c..79c2334 100644
--- a/src/apt/repositories.rs
+++ b/src/apt/repositories.rs
@@ -6,7 +6,8 @@ mod export {
use serde::{Deserialize, Serialize};
use proxmox_apt::repositories::{
- APTRepositoryFile, APTRepositoryFileError, APTRepositoryInfo, APTStandardRepository,
+ APTRepositoryFile, APTRepositoryFileError, APTRepositoryHandle, APTRepositoryInfo,
+ APTStandardRepository,
};
#[derive(Deserialize, Serialize)]
@@ -56,12 +57,15 @@ mod export {
}
/// Add the repository identified by the `handle`.
+ /// If the repository is already configured, it will be set to enabled.
///
/// The `digest` parameter asserts that the configuration has not been modified.
#[export]
pub fn add_repository(handle: &str, digest: Option<&str>) -> Result<(), Error> {
let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?;
+ let handle: APTRepositoryHandle = handle.try_into()?;
+
if let Some(digest) = digest {
let expected_digest = proxmox::tools::hex_to_digest(digest)?;
if expected_digest != current_digest {
@@ -69,8 +73,23 @@ mod export {
}
}
- let (repo, path) =
- proxmox_apt::repositories::get_standard_repository(handle.try_into()?, "pve")?;
+ // check if it's already configured first
+ for file in files.iter_mut() {
+ for repo in file.repositories.iter_mut() {
+ if repo.is_referenced_repository(handle, "pve") {
+ if repo.enabled {
+ return Ok(());
+ }
+
+ repo.set_enabled(true);
+ file.write()?;
+
+ return Ok(());
+ }
+ }
+ }
+
+ let (repo, path) = proxmox_apt::repositories::get_standard_repository(handle, "pve")?;
if let Some(error) = errors.iter().find(|error| error.path == path) {
bail!(
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] applied-series: [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes
2021-07-01 7:53 [pve-devel] [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Fabian Ebner
` (2 preceding siblings ...)
2021-07-01 9:01 ` [pve-devel] [PATCH pve-rs] apt: check if repository is already configured before adding Fabian Ebner
@ 2021-07-02 11:03 ` Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2021-07-02 11:03 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Ebner
On 01.07.21 09:53, Fabian Ebner wrote:
> proxmox-widget-toolkit:
>
> Fabian Ebner (1):
> apt repos: use correct URL
>
> src/node/APTRepositories.js | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>
> pve-rs:
>
> Fabian Ebner (1):
> apt: avoid overwriting files that could not be parsed
>
> src/apt/repositories.rs | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
applied series, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-02 11:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 7:53 [pve-devel] [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Fabian Ebner
2021-07-01 7:53 ` [pve-devel] [PATCH proxmox-widget-toolkit 1/1] apt repos: use correct URL Fabian Ebner
2021-07-01 7:54 ` [pve-devel] [PATCH pve-rs 1/1] apt: avoid overwriting files that could not be parsed Fabian Ebner
2021-07-01 9:01 ` [pve-devel] [PATCH pve-rs] apt: check if repository is already configured before adding Fabian Ebner
2021-07-02 11:03 ` [pve-devel] applied-series: [PATCH-SERIES proxmox-widget-toolkit/pve-rs] Two more APT repo fixes Thomas Lamprecht
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal