mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-10 08:51:12 +00:00
Merge branch 'dev' of https://github.com/telegramdesktop/tdesktop into dev
This commit is contained in:
commit
9fcd878f1d
@ -49,12 +49,13 @@ bool do_mkdir(const char *path) { // from http://stackoverflow.com/questions/675
|
||||
}
|
||||
|
||||
bool _debug = false;
|
||||
string exeName, exeDir, workDir;
|
||||
|
||||
FILE *_logFile = 0;
|
||||
void openLog() {
|
||||
if (!_debug || _logFile) return;
|
||||
|
||||
if (!do_mkdir("DebugLogs")) {
|
||||
if (!do_mkdir((workDir + "DebugLogs").c_str())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,7 +66,7 @@ void openLog() {
|
||||
|
||||
static const int maxFileLen = 65536;
|
||||
char logName[maxFileLen];
|
||||
sprintf(logName, "DebugLogs/%04d%02d%02d_%02d%02d%02d_upd.txt",
|
||||
sprintf(logName, "%sDebugLogs/%04d%02d%02d_%02d%02d%02d_upd.txt", workDir.c_str(),
|
||||
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
||||
_logFile = fopen(logName, "w");
|
||||
}
|
||||
@ -192,8 +193,6 @@ bool mkpath(const char *path) {
|
||||
return do_mkdir(path);
|
||||
}
|
||||
|
||||
string exeName, exeDir, workDir;
|
||||
|
||||
bool equal(string a, string b) {
|
||||
std::transform(a.begin(), a.end(), a.begin(), ::tolower);
|
||||
std::transform(b.begin(), b.end(), b.begin(), ::tolower);
|
||||
@ -204,7 +203,7 @@ void delFolder() {
|
||||
string delPathOld = workDir + "tupdates/ready", delPath = workDir + "tupdates/temp", delFolder = workDir + "tupdates";
|
||||
writeLog("Fully clearing old path '%s'..", delPathOld.c_str());
|
||||
if (!remove_directory(delPathOld)) {
|
||||
writeLog("Error: failed to clear old path! :(");
|
||||
writeLog("Failed to clear old path! :( New path was used?..");
|
||||
}
|
||||
writeLog("Fully clearing path '%s'..", delPath.c_str());
|
||||
if (!remove_directory(delPath)) {
|
||||
@ -221,9 +220,11 @@ bool update() {
|
||||
FILE *readyFile = fopen(readyFilePath.c_str(), "rb");
|
||||
if (readyFile) {
|
||||
fclose(readyFile);
|
||||
} else {
|
||||
updDir = workDir + "tupdates/ready"; // old
|
||||
}
|
||||
writeLog("Ready file found! Using new path '%s'..", updDir.c_str());
|
||||
} else {
|
||||
updDir = workDir + "tupdates/ready"; // old
|
||||
writeLog("Ready file not found! Using old path '%s'..", updDir.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
deque<string> dirs;
|
||||
@ -315,10 +316,6 @@ bool update() {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
openLog();
|
||||
|
||||
writeLog("Updater started..");
|
||||
|
||||
bool needupdate = true, autostart = false, debug = false, tosettings = false, startintray = false, testmode = false;
|
||||
|
||||
char *key = 0;
|
||||
@ -342,6 +339,12 @@ int main(int argc, char *argv[]) {
|
||||
workDir = argv[i];
|
||||
}
|
||||
}
|
||||
openLog();
|
||||
|
||||
writeLog("Updater started..");
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
writeLog("Argument: '%s'", argv[i]);
|
||||
}
|
||||
if (needupdate) writeLog("Need to update!");
|
||||
if (autostart) writeLog("From autostart!");
|
||||
|
||||
|
@ -55,8 +55,14 @@ void writeLog(NSString *msg) {
|
||||
}
|
||||
|
||||
void delFolder() {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[workDir stringByAppendingString:@"tupdates/ready"] error:nil]; // remove old
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[workDir stringByAppendingString:@"tupdates/temp"] error:nil];
|
||||
writeLog([@"Fully clearing old path: " stringByAppendingString:[workDir stringByAppendingString:@"tupdates/ready"]]);
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:[workDir stringByAppendingString:@"tupdates/ready"] error:nil]) {
|
||||
writeLog(@"Failed to clear old path! :( New path was used?..");
|
||||
}
|
||||
writeLog([@"Fully clearing new path: " stringByAppendingString:[workDir stringByAppendingString:@"tupdates/temp"]]);
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:[workDir stringByAppendingString:@"tupdates/temp"] error:nil]) {
|
||||
writeLog(@"Error: failed to clear new path! :(");
|
||||
}
|
||||
rmdir([[workDir stringByAppendingString:@"tupdates"] fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
@ -136,9 +142,12 @@ int main(int argc, const char * argv[]) {
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *readyFilePath = [workDir stringByAppendingString:@"tupdates/temp/ready"];
|
||||
NSString *srcDir = [workDir stringByAppendingString:@"tupdates/temp/"], *srcEnum = [workDir stringByAppendingString:@"tupdates/temp"];
|
||||
if (![fileManager fileExistsAtPath:readyFilePath]) {
|
||||
if ([fileManager fileExistsAtPath:readyFilePath]) {
|
||||
writeLog([@"Ready file found! Using new path: " stringByAppendingString: srcEnum]);
|
||||
} else {
|
||||
srcDir = [workDir stringByAppendingString:@"tupdates/ready/"]; // old
|
||||
srcEnum = [workDir stringByAppendingString:@"tupdates/ready"];
|
||||
writeLog([@"Ready file not found! Using old path: " stringByAppendingString: srcEnum]);
|
||||
}
|
||||
|
||||
writeLog([@"Starting update files iteration, path: " stringByAppendingString: srcEnum]);
|
||||
|
Loading…
Reference in New Issue
Block a user