Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KAlarm
Commits
3965ef11
Commit
3965ef11
authored
Dec 14, 2021
by
David Jarvie
Browse files
Treat empty read-only, or non-existent, calendar files as loaded
parent
e0449030
Pipeline
#109588
passed with stage
in 1 minute and 36 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
3965ef11
...
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set
(
PIM_VERSION
"5.19.1"
)
set
(
PIM_VERSION
${
PIM_VERSION
}
)
set
(
RELEASE_SERVICE_VERSION
"21.12.1"
)
set
(
KALARM_VERSION
"3.3.
3
"
)
set
(
KALARM_VERSION
"3.3.
4
"
)
project
(
kalarm VERSION
${
KALARM_VERSION
}
)
...
...
Changelog
View file @
3965ef11
KAlarm Change Log
=== Version 3.3.4 (KDE Applications 21.12.1) --- 14 December 2021 ===
* Treat empty read-only, or non-existent, calendar files as loaded.
=== Version 3.3.3 (KDE Applications 21.12) --- 7 November 2021 ===
* Show numbers in localised form.
* Make time edit spinboxes show time using localised format and numbers.
...
...
src/resources/singlefileresource.cpp
View file @
3965ef11
...
...
@@ -207,7 +207,7 @@ int SingleFileResource::doLoad(QHash<QString, KAEvent>& newEvents, bool readThro
// The resource's location should never change, so this code should
// never be reached!
qCWarning
(
KALARM_LOG
)
<<
"SingleFileResource::load:"
<<
displayId
()
<<
"Error? File location changed to"
<<
localFileName
;
setLoadFailure
();
setLoadFailure
(
true
);
mFileStorage
.
clear
();
mCalendar
.
clear
();
mLoadedEvents
.
clear
();
...
...
@@ -230,7 +230,22 @@ int SingleFileResource::doLoad(QHash<QString, KAEvent>& newEvents, bool readThro
errorMessage
=
xi18nc
(
"@info"
,
"Could not create calendar file <filename>%1</filename>."
,
path
);
mStatus
=
Status
::
Broken
;
mSaveUrl
.
clear
();
setLoadFailure
();
setLoadFailure
(
false
);
return
-
1
;
}
// Check whether this user can actually write to the newly created file.
// This might not tally with the open() permissions, since there are
// circumstances on Linux where a file created by a user can be owned by root.
QFile
fnew
(
localFileName
);
if
(
!
fnew
.
isWritable
())
{
fnew
.
remove
();
const
QString
path
=
mSettings
->
displayLocation
();
qCWarning
(
KALARM_LOG
)
<<
"SingleFileResource::load:"
<<
displayId
()
<<
"Could not create writable file"
<<
path
;
errorMessage
=
xi18nc
(
"@info"
,
"Could not create calendar file <filename>%1</filename>."
,
path
);
mStatus
=
Status
::
Broken
;
mSaveUrl
.
clear
();
setLoadFailure
(
false
);
return
-
1
;
}
mFileReadOnly
=
false
;
...
...
@@ -270,7 +285,7 @@ int SingleFileResource::doLoad(QHash<QString, KAEvent>& newEvents, bool readThro
qCWarning
(
KALARM_LOG
)
<<
"SingleFileResource::load:"
<<
displayId
()
<<
"Could not read file"
<<
localFileName
;
// A user error message has been set by readLocalFile().
mStatus
=
Status
::
Broken
;
setLoadFailure
();
setLoadFailure
(
true
);
return
-
1
;
}
...
...
@@ -282,12 +297,17 @@ int SingleFileResource::doLoad(QHash<QString, KAEvent>& newEvents, bool readThro
return
1
;
// success
}
void
SingleFileResource
::
setLoadFailure
()
/******************************************************************************
* Called when loading fails.
* If the resource file doesn't exist or can't be created, the resource is still
* regarded as loaded.
*/
void
SingleFileResource
::
setLoadFailure
(
bool
exists
)
{
mLoadedEvents
.
clear
();
QHash
<
QString
,
KAEvent
>
events
;
setLoadedEvents
(
events
);
setLoaded
(
false
);
setLoaded
(
!
exists
);
}
/******************************************************************************
...
...
@@ -526,6 +546,8 @@ bool SingleFileResource::doDeleteEvent(const KAEvent& event)
*/
bool
SingleFileResource
::
readLocalFile
(
const
QString
&
fileName
,
QString
&
errorMessage
)
{
if
(
mFileReadOnly
&&
!
QFileInfo
(
fileName
).
size
())
return
true
;
const
QByteArray
newHash
=
calculateHash
(
fileName
);
if
(
newHash
==
mCurrentHash
)
qCDebug
(
KALARM_LOG
)
<<
"SingleFileResource::readLocalFile:"
<<
displayId
()
<<
"hash unchanged"
;
...
...
@@ -698,7 +720,7 @@ void SingleFileResource::slotDownloadJobResult(KJob* job)
{
if
(
mStatus
!=
Status
::
Closed
)
mStatus
=
Status
::
Broken
;
setLoadFailure
();
setLoadFailure
(
false
);
const
QString
path
=
mSettings
->
displayLocation
();
qCWarning
(
KALARM_LOG
)
<<
"SingleFileResource::slotDownloadJobResult:"
<<
displayId
()
<<
"Could not load file"
<<
path
<<
job
->
errorString
();
errorMessage
=
xi18nc
(
"@info"
,
"Could not load file <filename>%1</filename>. (%2)"
,
path
,
job
->
errorString
());
...
...
@@ -713,7 +735,7 @@ void SingleFileResource::slotDownloadJobResult(KJob* job)
// A user error message has been set by readLocalFile().
if
(
mStatus
!=
Status
::
Closed
)
mStatus
=
Status
::
Broken
;
setLoadFailure
();
setLoadFailure
(
true
);
success
=
false
;
}
else
if
(
mStatus
!=
Status
::
Closed
)
...
...
src/resources/singlefileresource.h
View file @
3965ef11
...
...
@@ -198,7 +198,7 @@ private Q_SLOTS:
bool
addLoadedEvent
(
const
KCalendarCore
::
Event
::
Ptr
&
);
private:
void
setLoadFailure
();
void
setLoadFailure
(
bool
exists
);
QUrl
mSaveUrl
;
// current local file for save() to use (may be temporary)
KIO
::
FileCopyJob
*
mDownloadJob
{
nullptr
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment