From 1f92b89e16ea4109a93fe49122099ef081fcb5e4 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 22 Apr 2017 21:56:37 +0200 Subject: [PATCH] WIP: Don't allow to edit downloaded packages. --- src/lay/laySaltGrain.cc | 4 +++- src/lay/laySaltManagerDialog.cc | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lay/laySaltGrain.cc b/src/lay/laySaltGrain.cc index 83ed47e4f..d39664ad5 100644 --- a/src/lay/laySaltGrain.cc +++ b/src/lay/laySaltGrain.cc @@ -337,7 +337,9 @@ SaltGrain::xml_struct () bool SaltGrain::is_readonly () const { - return !QFileInfo (tl::to_qstring (path ())).isWritable (); + // A grain is readonly if the directory is not writable or there is a download URL + // (this means the grain has been installed from an URL). + return !QFileInfo (tl::to_qstring (path ())).isWritable () || !m_url.empty (); } void diff --git a/src/lay/laySaltManagerDialog.cc b/src/lay/laySaltManagerDialog.cc index 6fb4dc59c..d71be4edb 100644 --- a/src/lay/laySaltManagerDialog.cc +++ b/src/lay/laySaltManagerDialog.cc @@ -512,7 +512,10 @@ SaltManagerDialog::edit_properties () { SaltGrain *g = current_grain (); if (g) { - if (mp_properties_dialog->exec_dialog (g, mp_salt)) { + if (g->is_readonly ()) { + QMessageBox::critical (this, tr ("Package is not Editable"), + tr ("This package cannot be edited.\n\nEither you don't have write permissions on the directory or the package was installed from a repository.")); + } else if (mp_properties_dialog->exec_dialog (g, mp_salt)) { current_changed (); } }