Bug 259731 - archive old events action not working
Summary: archive old events action not working
Status: VERIFIED FIXED
Alias: None
Product: KOrganizer Mobile
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Windows CE Microsoft Windows CE
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-13 14:55 UTC by Ludwig Reiter
Modified: 2011-02-15 17:18 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Reiter 2010-12-13 14:55:31 UTC
Version:           unspecified (using Devel) 
OS:                Windows CE

version: 20101209 svn-1204839

I looked for the archive old events action in the different flaps, bur couldn't find it. It is missing.

Reproducible: Always
Comment 1 Ludwig Reiter 2010-12-14 10:03:16 UTC
Opps, I have seen this action today.
I need to test it.
Comment 2 Ludwig Reiter 2010-12-16 14:30:22 UTC
tested the archive function.

version: 2010-12-15 svn-1206816

Archive dialog opens.
But entering a file name and pressing on the archive button doesn't have an effect.
Comment 3 Tobias Koenig 2010-12-20 13:35:39 UTC
Hej Ludwig,

so the events that match the given date filter pattern are not archived to the file?

Ciao,
Tobias
Comment 4 Ludwig Reiter 2010-12-20 15:32:40 UTC
Clicking on the archive button doesn't have an effect.
The dialog doesn't close and no archive is written.
I need to  press "Cancel" to close the dialog.
(Entered a filename manually)
Comment 5 Andre Heinecke 2011-01-12 09:27:46 UTC
One thing i noticed is that it can only be called if a subfolder is selected that might have lead to the initial "where is it" confusion.

This means if you have a local Calendar ressources with no subfolders you can not select archive old entries from the menu.
Comment 6 Andre Heinecke 2011-01-12 16:05:15 UTC
commit c5c727a06cd899ef9727e9a41b6529870524becd
branch master
Author: Andre Heinecke <aheinecke@intevation.de>
Date:   Wed Jan 12 12:02:23 2011 +0000

    Don't call KSaveFile with an already open File
    
        On Windows Systems files can not be removed when there are open
        Handles to them. This breaks the way KTemporaryFile and KSaveFile
        interact in this case.
        When archivestore::save is called a KSaveFile is created by the
        Filename which was already opened by KTemporaryFile so the renaming
        fails.
    
        CCBUG: 259731

diff --git a/calendarsupport/eventarchiver.cpp b/calendarsupport/eventarchiver.cpp
index 0a95f35..55d3280 100644
--- a/calendarsupport/eventarchiver.cpp
+++ b/calendarsupport/eventarchiver.cpp
@@ -176,10 +176,18 @@ void EventArchiver::archiveIncidences( CalendarSupport::Calendar *calendar, Cale
   CalendarSupport::CalendarAdaptor::Ptr cal( new CalendarSupport::CalendarAdaptor( calendar, widget ) );
   FileStorage storage( cal );
 
+  QString tmpFileName;
+  // KSaveFile can not be called with an open File Handle on Windows.
+  // So we use KTemporaryFile only to generate a unique filename
+  // and then close/delete the file again. This file must be deleted
+  // here.
+  {
+    KTemporaryFile tmpFile;
+    tmpFile.open();
+    tmpFileName = tmpFile.fileName();
+  }
   // Save current calendar to disk
-  KTemporaryFile tmpFile;
-  tmpFile.open();
-  storage.setFileName( tmpFile.fileName() );
+  storage.setFileName( tmpFileName );
   if ( !storage.save() ) {
     kDebug() << "Can't save calendar to temp file";
     return;
@@ -190,11 +198,12 @@ void EventArchiver::archiveIncidences( CalendarSupport::Calendar *calendar, Cale
     new MemoryCalendar( CalendarSupport::KCalPrefs::instance()->timeSpec() ) );
 
   FileStorage archiveStore( archiveCalendar );
-  archiveStore.setFileName( tmpFile.fileName() );
+  archiveStore.setFileName( tmpFileName );
   ICalFormat *format = new ICalFormat();
   archiveStore.setSaveFormat( format );
   if ( !archiveStore.load() ) {
     kDebug() << "Can't load calendar from temp file";
+    QFile::remove( tmpFileName );
     return;
   }
 
@@ -218,16 +227,18 @@ void EventArchiver::archiveIncidences( CalendarSupport::Calendar *calendar, Cale
   if ( KIO::NetAccess::exists( archiveURL, KIO::NetAccess::SourceSide, widget ) ) {
     if( !KIO::NetAccess::download( archiveURL, archiveFile, widget ) ) {
       kDebug() << "Can't download archive file";
+      QFile::remove( tmpFileName );
       return;
     }
     // Merge with events to be archived.
     archiveStore.setFileName( archiveFile );
     if ( !archiveStore.load() ) {
       kDebug() << "Can't merge with archive file";
+      QFile::remove( tmpFileName );
       return;
     }
   } else {
-    archiveFile = tmpFile.fileName();
+    archiveFile = tmpFileName;
   }
 
   // Save archive calendar
@@ -240,6 +251,7 @@ void EventArchiver::archiveIncidences( CalendarSupport::Calendar *calendar, Cale
     }
     KMessageBox::error( widget, i18n( "Cannot write archive file %1. %2",
                                       archiveStore.fileName(), errmess ) );
+    QFile::remove( tmpFileName );
     return;
   }
 
@@ -250,10 +262,12 @@ void EventArchiver::archiveIncidences( CalendarSupport::Calendar *calendar, Cale
     if ( !KIO::NetAccess::upload( archiveFile, archiveURL, widget ) ) {
       KMessageBox::error( widget, i18n( "Cannot write archive. %1",
                                         KIO::NetAccess::lastErrorString() ) );
+      QFile::remove( tmpFileName );
       return;
     }
   }
 
+  QFile::remove( tmpFileName );
   KIO::NetAccess::removeTempFile( archiveFile );
 
   // Delete archived events from calendar
Comment 7 Andre Heinecke 2011-01-12 16:09:49 UTC
Tested on my development device i was able to archive old entries.
Comment 8 Ludwig Reiter 2011-01-17 14:57:18 UTC
test windows CE 2011-01-16 git-4d1bc61

archive many events with attendee doesn't work: The user is asked many times if he wants to send an update.
The user should be asked once to send updates or not.
Comment 9 Sergio Martins 2011-01-20 13:35:04 UTC
Git commit 24891f2cbf64d11bf72ce7b14e2e3823d6c63773 by Sergio Martins
Pushed by smartins into branch master

Deleting a batch of incidences should be an atomic operation.

Otherwise, When deleting 1000 events you'll be asked 1000 times
if you want to send invitations.

CCBUG: 259731

M  +6    -1    calendarsupport/eventarchiver.cpp     

http://commits.kde.org/ee6cc38b/24891f2cbf64d11bf72ce7b14e2e3823d6c63773
Comment 10 Sergio Martins 2011-01-20 13:38:39 UTC
Not working yet, need to fix another bug.
Comment 11 Sergio Martins 2011-01-20 16:14:32 UTC
Git commit 729312ee1310b9b910fbe6be7fd63cc468a86ba3 by Sergio Martins
Pushed by smartins into branch master

Only ask once to send invitations when batch removing them.

BUG:259731

M  +2    -0    calendarsupport/incidencechanger.cpp     

http://commits.kde.org/ee6cc38b/729312ee1310b9b910fbe6be7fd63cc468a86ba3
Comment 12 Andre Heinecke 2011-02-15 17:18:19 UTC
Both archiving in general and the update question work.