Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
Okular
Commits
d9d09ef7
Commit
d9d09ef7
authored
Sep 09, 2021
by
Albert Astals Cid
Browse files
Don't allow saving over read-only files
BUGS: 440986
parent
7c87c702
Pipeline
#80995
passed with stage
in 27 minutes and 43 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
part/part.cpp
View file @
d9d09ef7
...
...
@@ -2545,6 +2545,15 @@ bool Part::saveAs(const QUrl &saveUrl, SaveAsFlags flags)
// Figure out the real save url, for symlinks we don't want to copy over the symlink but over the target file
const
QUrl
realSaveUrl
=
resolveSymlinksIfFileExists
(
saveUrl
);
// Due to the way we write we can overwrite readonly files so check if it's one and just bail out early
if
(
realSaveUrl
.
isLocalFile
())
{
const
QFileInfo
fi
(
realSaveUrl
.
toLocalFile
());
if
(
fi
.
exists
()
&&
!
fi
.
isWritable
())
{
KMessageBox
::
information
(
widget
(),
i18n
(
"File could not be saved in '%1'. Try to save it to another location."
,
realSaveUrl
.
toLocalFile
()));
return
false
;
}
}
QScopedPointer
<
QTemporaryFile
>
tempFile
;
KIO
::
Job
*
copyJob
=
nullptr
;
// this will be filled with the job that writes to saveUrl
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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