Skip to content

Commit

Permalink
[buteo-mtp] Fix unable of copy big files to SD card over MTP. Fixes J…
Browse files Browse the repository at this point in the history
…B#50733.

The problem is unable to copy big file (more 300 Mb) from host PC
to SD card over MTP. At Linux after about 1-2 minutes from start:
"libmtp error: Could not send object property list".
Files appears but MD sums are not matched.
At Windows on laptop: after about 1-2 minutes the copy progress
bar disappears without any notification.

It seems that ftruncate (called
from fsstorageplugin.cpp:1305
...
if( !file.resize(size))
...
for big file continues too long, because it tries to fill memory
on SD with zeros.
strace -r /usr/lib/mtp/mtp_service
...
0.000400 ftruncate64(21, 584411895) = 0
124.915724 close(21)                 = 0
...
So PC host close connection by timeout.

For resolve this issue we can use another method memory allocation.
  • Loading branch information
Dmitry Andreev committed Aug 7, 2020
1 parent a11c58d commit a060333
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mts/platform/storage/fsstorageplugin/fsstorageplugin.cpp
Expand Up @@ -2,6 +2,7 @@
* This file is part of libmeegomtp package
*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* Contact: Deepak Kodihalli <deepak.kodihalli@nokia.com>
*
Expand Down Expand Up @@ -41,6 +42,7 @@
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>

#include <QDebug>
#include <QFile>
Expand Down Expand Up @@ -1032,7 +1034,7 @@ MTPResponseCode FSStoragePlugin::createFile( const QString &path, MTPObjectInfo
/* Resize to expected content length */
quint64 size = info ? info->mtpObjectCompressedSize : 0;

if( !file.resize(size) ) {
if( fallocate(file.handle(), 0, 0, size) ) {
MTP_LOG_WARNING("failed to set file:" << path << " to size:" << size);
}

Expand Down

0 comments on commit a060333

Please sign in to comment.