Fix build, add logs for sendfile().
This commit is contained in:
parent
99b9a46428
commit
3cad89f299
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/sendfile.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -113,11 +114,23 @@ bool copyFile(const char *from, const char *to) {
|
||||||
fst.st_size);
|
fst.st_size);
|
||||||
|
|
||||||
if (copied == -1) {
|
if (copied == -1) {
|
||||||
|
writeLog(
|
||||||
|
"Copy by sendfile '%s' to '%s' failed, error: %d, fallback now.",
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
int(errno));
|
||||||
static const int BufSize = 65536;
|
static const int BufSize = 65536;
|
||||||
char buf[BufSize];
|
char buf[BufSize];
|
||||||
while (size_t size = fread(buf, 1, BufSize, ffrom)) {
|
while (size_t size = fread(buf, 1, BufSize, ffrom)) {
|
||||||
fwrite(buf, 1, size, fto);
|
fwrite(buf, 1, size, fto);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
writeLog(
|
||||||
|
"Copy by sendfile '%s' to '%s' done, size: %d, result: %d.",
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
int(fst.st_size),
|
||||||
|
int(copied));
|
||||||
}
|
}
|
||||||
|
|
||||||
//update to the same uid/gid
|
//update to the same uid/gid
|
||||||
|
|
|
@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/sendfile.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -1039,13 +1040,25 @@ bool linuxMoveFile(const char *from, const char *to) {
|
||||||
nullptr,
|
nullptr,
|
||||||
fst.st_size);
|
fst.st_size);
|
||||||
#endif // Q_OS_LINUX
|
#endif // Q_OS_LINUX
|
||||||
|
|
||||||
if (copied == -1) {
|
if (copied == -1) {
|
||||||
|
DEBUG_LOG(("Update Error: "
|
||||||
|
"Copy by sendfile '%1' to '%2' failed, error: %3, fallback now."
|
||||||
|
).arg(from
|
||||||
|
).arg(to
|
||||||
|
).arg(errno));
|
||||||
static const int BufSize = 65536;
|
static const int BufSize = 65536;
|
||||||
char buf[BufSize];
|
char buf[BufSize];
|
||||||
while (size_t size = fread(buf, 1, BufSize, ffrom)) {
|
while (size_t size = fread(buf, 1, BufSize, ffrom)) {
|
||||||
fwrite(buf, 1, size, fto);
|
fwrite(buf, 1, size, fto);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG_LOG(("Update Info: "
|
||||||
|
"Copy by sendfile '%1' to '%2' done, size: %3, result: %4."
|
||||||
|
).arg(from
|
||||||
|
).arg(to
|
||||||
|
).arg(fst.st_size
|
||||||
|
).arg(copied));
|
||||||
}
|
}
|
||||||
|
|
||||||
//update to the same uid/gid
|
//update to the same uid/gid
|
||||||
|
|
Loading…
Reference in New Issue