mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fix build, add logs for sendfile().
This commit is contained in:
parent
99b9a46428
commit
3cad89f299
2 changed files with 27 additions and 1 deletions
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <cstdio>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
@ -113,11 +114,23 @@ bool copyFile(const char *from, const char *to) {
|
|||
fst.st_size);
|
||||
|
||||
if (copied == -1) {
|
||||
writeLog(
|
||||
"Copy by sendfile '%s' to '%s' failed, error: %d, fallback now.",
|
||||
from,
|
||||
to,
|
||||
int(errno));
|
||||
static const int BufSize = 65536;
|
||||
char buf[BufSize];
|
||||
while (size_t size = fread(buf, 1, BufSize, ffrom)) {
|
||||
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
|
||||
|
|
|
@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
@ -1039,13 +1040,25 @@ bool linuxMoveFile(const char *from, const char *to) {
|
|||
nullptr,
|
||||
fst.st_size);
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
|
||||
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;
|
||||
char buf[BufSize];
|
||||
while (size_t size = fread(buf, 1, BufSize, ffrom)) {
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue