Make file ioslave backend on removeables are user-frendly on linux
Needs RevisionPublic

Authored by vova7890 on Oct 11 2017, 10:52 PM.

Details

Reviewers
dfaure
ossi
thiago
Group Reviewers
Frameworks
Summary

Currently on linux copying file on the flash drive is showing momental progress 0 -> 100% and at the end of 100% is waiting while file are flushed on the drive.
This is almost linux bug with dirty_cache, but had another way to write the file. This patch is implements by checking what drive has dest file, and tryng to optimize of file writing by cheking is the device are "removable"(if true - appends O_SYNC for ::open) and how many kbytes device can transfer per single transfer. So for now, the progress bar is shows real percent of progress and abort or pause is working are propertly.

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
vova7890 created this revision.Oct 11 2017, 10:52 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 11 2017, 10:53 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
dfaure requested changes to this revision.Dec 2 2017, 4:05 PM
dfaure added a subscriber: dfaure.

I suppose put() should do the same, then?

b/src/ioslaves/file/file_unix.cpp
72

Doesn't KMountPoint::currentMountPoints + findByPath already do this?

107

Probably not, I don't see another user than kio_file for such detailed information.

226

... and then the code says 1024*1024 ;)

A comment shouldn't say "what" (the code does that), but "why".
If there's no need to document "why", remove the comment.

229

make that &block_size and &is_removeable so that when reading this line it's clear that those are in+out vars.

232

use std::clamp, this way you won't even have to repeat the min and max values.

241

The conversion via std::string is incorrect, encoding wise.

The way to pass a QString (for a filename) to a system call is QFile::encodeName().

289

C casts make me puke ;)
The C++ way would be reinterpret_cast, but I don't think you even need that. It compiled with a char* before, so just use buffer.data()

324

.data() is more readable

This revision now requires changes to proceed.Dec 2 2017, 4:05 PM
ossi added inline comments.Dec 3 2017, 1:58 PM
b/src/ioslaves/file/file_unix.cpp
241

you want O_DSYNC