D12019: make sure to create unique filename in maildir resource
Daniel Vrátil
noreply at phabricator.kde.org
Mon Apr 9 10:22:44 BST 2018
dvratil added a comment.
I wonder if this won't make the filenames unnecessarily long. I think that just simply switching to QDateTime::currentMSecsSinceEpoch() would give us enough granularity. There's basically no chance that createUniqueFileName() would be called twice in a single millisecond, and even if so, the chance of two consecutive qrand()s generating the same pseudorandom number reduces the chance of a conflict even further.
INLINE COMMENTS
> maildir.cpp:552-554
> + QString uuid = QUuid::createUuid().toString().mid(1); // remove leading '{'
> + uuid.chop(1); // remove trailing '}'
> + QString fileName = uuid + QLatin1Char('.');
I would suggest
auto uuid = QUuid::createUuid().toString();
uuid[uuid.size() - 1] = '.'
return uuid.mid(1);
to avoid unnecessary string copying.
REPOSITORY
R44 KDE PIM Runtime
REVISION DETAIL
https://phabricator.kde.org/D12019
To: mkoller, mlaurent
Cc: dvratil, #kde_pim, dvasin, winterz, vkrause, mlaurent, knauss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20180409/503a54e3/attachment.html>
More information about the kde-pim
mailing list