Diffusion KIO 578fbf45297b

Add truncation support to FileJob

Authored by feverfew on Dec 24 2019, 10:05 PM.

Description

Add truncation support to FileJob

Summary:
This patch adds support for truncation for FileJob via creation of a
FileJob->truncate(KIO::filesize_t length) method.
It also implements this function in the file slave.
The patch also adds a "truncating" field to the protocol file, thus making it
possible to determine if a protocol supports this new feature.

Currently within the FileJob class there is no native way to truncate an
open file. To achieve truncation, one has to do a FileJob->read() until the
truncation point and then do a KIO::put() to truncate accordingly. This brings
two undesirable issues:

  1. Incredibly wasteful and non-performant.
  2. One has to do IO outside of the FileJob interface. One has to make sure that

during the KIO::put(), there are no open file descriptors (created via
KIO::open()), as they would be invalidated by the KIO::put().

Adding native supports allows cleaner, more performant code and means that
the FileJob class is functionally complete in providing random-access I/O.

Test Plan:
Tested in conjunction with KIOFuse, does truncation
correctly.

Reviewers: fvogt, dfaure, sitter

Reviewed By: dfaure

Subscribers: apol, ngraham, sitter, dfaure, kde-frameworks-devel, fvogt

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D26148

Details

Committed
feverfewJan 1 2020, 11:59 PM
Reviewer
dfaure
Differential Revision
D26148: Add truncation support to FileJob
Parents
R241:c930030308cc: [KFileWidgets] Port QRegExp to QRegularExpression
Branches
Unknown
Tags
Unknown