mtp修复低概率复制粘贴图片文件大小不全问题

Signed-off-by: zhonglufu <zhonglufu@huawei.com>
This commit is contained in:
zhonglufu 2024-11-18 18:06:00 +08:00
parent b33d1b2dc8
commit abc77bfa1f

View File

@ -208,9 +208,7 @@ int WrapCreate(const char *path, mode_t mode, fuse_file_info *fileInfo)
int WrapTruncate(const char *path, off_t offset, struct fuse_file_info *fileInfo)
{
LOGI("mtp WrapTruncate");
int ret = DelayedSingleton<MtpFileSystem>::GetInstance()->Truncate(path, offset, fileInfo);
LOGI("Truncate ret = %{public}d.", ret);
return ret;
return 0;
}
int WrapReadLink(const char *path, char *out, size_t size)
@ -641,6 +639,7 @@ int MtpFileSystem::Truncate(const char *path, off_t new_size, struct fuse_file_i
return -rval;
}
rval = device_.FilePush(tmpPath, std::string(path));
::unlink(tmpPath.c_str());
if (rval != 0) {
return -rval;
}
@ -864,11 +863,6 @@ int MtpFileSystem::FSync(const char *path, int datasync, struct fuse_file_info *
if (rval != 0) {
return -errno;
}
const std::string stdPath(path);
MtpFsTypeTmpFile *tmpFile = const_cast<MtpFsTypeTmpFile *>(tmpFilesPool_.GetFile(stdPath));
if (tmpFile != nullptr) {
tmpFile->RemoveFileDescriptor(fi->fh);
}
return 0;
}