Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
Konqueror
Commits
e67bca8f
Commit
e67bca8f
authored
Jul 18, 2020
by
Stefano Crocco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly simplify the algorithm to generate the blob file name
parent
93edffa8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
webenginepart/src/webenginepartdownloadmanager.cpp
webenginepart/src/webenginepartdownloadmanager.cpp
+13
-11
No files found.
webenginepart/src/webenginepartdownloadmanager.cpp
View file @
e67bca8f
...
...
@@ -167,25 +167,27 @@ void WebEnginePartDownloadManager::openBlob(QWebEngineDownloadItem* it, WebEngin
QString
WebEnginePartDownloadManager
::
generateBlobTempFileName
(
const
QString
&
suggestedName
,
const
QString
&
ext
)
const
{
QDir
tmpDir
(
m_tempDownloadDir
.
path
());
QString
fileName
;
QString
actualExt
=
ext
;
if
(
!
suggestedName
.
isEmpty
())
{
fileName
=
tmpDir
.
filePath
(
suggestedName
);
QString
givenExt
=
QFileInfo
(
fileName
).
completeSuffix
();
QString
baseName
(
suggestedName
);
QString
actualExt
(
ext
);
if
(
!
baseName
.
isEmpty
())
{
QString
givenExt
=
QFileInfo
(
baseName
).
completeSuffix
();
if
(
!
givenExt
.
isEmpty
())
{
actualExt
=
givenExt
;
//Remove the extension from fileName. The -1 is needed to also remove the dot
fileName
=
fileName
.
left
(
fileName
.
length
()
-
givenExt
.
length
()
-
1
);
//The +1 is for the dot
int
extLength
=
givenExt
.
length
()
+
1
;
//Remove the extension from baseName
baseName
.
remove
(
baseName
.
length
()
-
extLength
,
extLength
);
}
}
else
{
fil
eName
=
tmpDir
.
filePath
(
QString
::
number
(
QTime
::
currentTime
().
msecsSinceStartOfDay
())
)
;
bas
eName
=
QString
::
number
(
QTime
::
currentTime
().
msecsSinceStartOfDay
());
}
QString
completeName
=
fileName
+
"."
+
actualExt
;
baseName
=
tmpDir
.
filePath
(
baseName
);
QString
completeName
=
QString
(
"%1.%2"
).
arg
(
baseName
,
actualExt
);
QString
nameTemplate
=
"%1-%2.%3"
;
int
i
=
0
;
while
(
tmpDir
.
exists
(
completeName
))
{
while
(
QFileInfo
::
exists
(
completeName
))
{
++
i
;
completeName
=
nameTemplate
.
arg
(
fil
eName
).
arg
(
i
).
arg
(
actualExt
);
completeName
=
nameTemplate
.
arg
(
bas
eName
).
arg
(
i
).
arg
(
actualExt
);
}
return
completeName
;
}
...
...
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