Bug 87116 - Korganizer tries to save read-only resources
Summary: Korganizer tries to save read-only resources
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: Cornelius Schumacher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-13 13:08 UTC by Jarkko Suontausta
Modified: 2004-09-14 21:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jarkko Suontausta 2004-08-13 13:08:01 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

Hello,

I have a local calendar resource that is marked read-only in korganizer, and that file is also write protected. When I save calendar resources either manually or by exiting korganizer, it also tries to save this read-only resource and shows an error message. This was not a problem with KDE 3.2, but with a ~1 week old CVS HEAD version it is.

I took a quick look at the sources, and it seems a check or two is missing from actionmanager.cpp(?). YMMV :)

-- Jarkko
Comment 1 Cornelius Schumacher 2004-08-13 13:50:25 UTC
Which resource shows the problem?
Comment 2 Jarkko Suontausta 2004-08-13 15:19:35 UTC
It's a "Calendar in local file" type of resource. Was this the answer you were looking for?
Comment 3 Cornelius Schumacher 2004-08-13 17:11:36 UTC
Yes, some resources (e.g. the remote resource) check for the read-only flag, some don't (e.g. the local resource). We should probably add a check in ResourceCalendar::save().
Comment 4 Jarkko Suontausta 2004-08-16 17:53:21 UTC
It really becomes a problem, if you set the auto-save-in-x-minutes to 10 minutes or so... Had to click through about a hundred of error dialogs when kontact was left running overnight :)
Comment 5 Cornelius Schumacher 2004-08-16 18:51:05 UTC
Yeah, had to do the same this morning.
Comment 6 Reinhold Kainhofer 2004-09-14 00:49:45 UTC
CVS commit by kainhofe: 

Don't even try to save read-only resources by default. So far, you couldn't edit the incidences in these resources, but everything was still written out to disk anew on exit. That just didn't make sense and was a waste of resources...

CCMAIL: 87116-done@bugs.kde.org


  M +11 -5     resourcecalendar.cpp   1.17


--- kdepim/libkcal/resourcecalendar.cpp  #1.16:1.17
@@ -125,4 +125,5 @@ void ResourceCalendar::loadError( const 
 bool ResourceCalendar::save()
 {
+  if ( !readOnly() ) {
   kdDebug(5800) << "Save resource " + resourceName() << endl;
 
@@ -133,4 +134,9 @@ bool ResourceCalendar::save()
 
   return success;
+  } else {
+    // Read-only, just don't save...
+    kdDebug(5800) << "Don't save read-only resource " + resourceName() << endl;
+    return true;
+  }
 }
 


Comment 7 Jarkko Suontausta 2004-09-14 18:38:11 UTC
Great, thank you! This makes it possible to uncheck a read-only resource from 
the list (previously KO would abort the unchecking because it couldn't save 
the resource). And obviously the fact that a read-only resource will not be 
modified unknowingly is a welcomed fix :)

Could you please backport this?

Comment 8 Reinhold Kainhofer 2004-09-14 21:22:21 UTC
CVS commit by kainhofe: 

Backport of fixes for bugs 87327 (directory for local dir resource was never automatically created, and all data of that resource was just lost) and 87116 (read-only resources were also saved, causing error message boxes if the file wasn't writable).

CCMAIL: 87327@bugs.kde.org, 87116@bugs.kde.org


  M +11 -5     resourcecalendar.cpp   1.15.2.1
  M +31 -20    resourcelocaldir.cpp   1.21.2.1


--- kdepim/libkcal/resourcecalendar.cpp  #1.15:1.15.2.1
@@ -114,4 +114,5 @@ void ResourceCalendar::loadError( const 
 bool ResourceCalendar::save()
 {
+  if ( !readOnly() ) { 
   kdDebug(5800) << "Save resource " + resourceName() << endl;
 
@@ -122,4 +123,9 @@ bool ResourceCalendar::save()
 
   return success;
+  } else { 
+    // Read-only, just don't save... 
+    kdDebug(5800) << "Don't save read-only resource " + resourceName() << endl; 
+    return true; 
+  } 
 }
 

--- kdepim/libkcal/resourcelocaldir.cpp  #1.21:1.21.2.1
@@ -30,4 +30,5 @@
 #include <klocale.h>
 #include <kurl.h>
+#include <kstandarddirs.h>
 
 #include "vcaldrag.h"
@@ -126,6 +127,15 @@ bool ResourceLocalDir::doLoad()
 
   mCalendar.close();
+  bool success = true;
 
   QString dirName = mURL.path();
+  if ( !KStandardDirs::exists( dirName ) ) {
+    kdDebug(5800) << "ResourceLocalDir::load(): Directory doesn't exist yet. Creating it..." << endl;
+    
+    // Create the directory. Use 0775 to allow group-writable if the umask 
+    // allows it (permissions will be 0775 & ~umask). This is desired e.g. for
+    // group-shared directories!
+    success = KStandardDirs::makeDir( dirName, 0775 );
+  } else {
 
   kdDebug(5800) << "ResourceLocalDir::load(): '" << dirName << "'" << endl;
@@ -148,6 +158,7 @@ bool ResourceLocalDir::doLoad()
     if ( i ) mCalendar.addIncidence( i->clone() );
   }
+  }
 
-  return true;
+  return success;
 }