mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-17 21:26:41 +02:00
Update PR
* Update PR
This commit is contained in:
parent
080a44b9d7
commit
c775ce6a69
|
@ -161,7 +161,7 @@ class CurlResponse {
|
|||
class CurlEngine {
|
||||
|
||||
__gshared static CurlEngine[] curlEnginePool; // __gshared is used for thread-shared static variables
|
||||
|
||||
|
||||
HTTP http;
|
||||
bool keepAlive;
|
||||
ulong dnsTimeout;
|
||||
|
@ -211,8 +211,8 @@ class CurlEngine {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void releaseAllCurlInstances() {
|
||||
|
||||
static void releaseAllCurlInstances() {
|
||||
synchronized (CurlEngine.classinfo) {
|
||||
// Safely iterate and clean up each CurlEngine instance
|
||||
foreach (CurlEngine curlEngine; curlEnginePool) {
|
||||
|
@ -230,7 +230,12 @@ class CurlEngine {
|
|||
// Clear the array after all instances have been handled
|
||||
curlEnginePool.length = 0; // More explicit than curlEnginePool = [];
|
||||
}
|
||||
// Destroy curlEnginePool, set to null
|
||||
}
|
||||
|
||||
static void destroyAllCurlInstances() {
|
||||
// Release all 'curl' instances
|
||||
releaseAllCurlInstances();
|
||||
// Destroy curlEnginePool, set to null
|
||||
object.destroy(curlEnginePool);
|
||||
curlEnginePool = null;
|
||||
}
|
||||
|
|
|
@ -107,8 +107,9 @@ class LogBuffer {
|
|||
// Use dnotify's functionality for GUI notifications, if GUI notifications is enabled
|
||||
version(Notifications) {
|
||||
try {
|
||||
auto n = new Notification("OneDrive Client for Linux", message, "IGNORED");
|
||||
//n.timeout = 5;
|
||||
auto n = new Notification("OneDrive Client", message, "IGNORED");
|
||||
// Show notification for 10 seconds
|
||||
n.timeout = 10;
|
||||
n.show();
|
||||
} catch (NotificationError e) {
|
||||
sendGUINotification = false;
|
||||
|
|
18
src/main.d
18
src/main.d
|
@ -994,13 +994,17 @@ int main(string[] cliArgs) {
|
|||
addLogEntry("End Monitor Loop Time: " ~ to!string(endFunctionProcessingTime), ["debug"]);
|
||||
addLogEntry("Elapsed Monitor Loop Processing Time: " ~ to!string((endFunctionProcessingTime - startFunctionProcessingTime)), ["debug"]);
|
||||
|
||||
// Display memory details before cleanup
|
||||
// Release all the curl instances used during this loop
|
||||
// New curl instances will be established on next loop
|
||||
CurlEngine.releaseAllCurlInstances();
|
||||
|
||||
// Display memory details before garbage collection
|
||||
if (displayMemoryUsage) displayMemoryUsagePreGC();
|
||||
// Perform Garbage Cleanup
|
||||
// Perform Garbage Collection
|
||||
GC.collect();
|
||||
// Return free memory to the OS
|
||||
GC.minimize();
|
||||
// Display memory details after cleanup
|
||||
// Display memory details after garbage collection
|
||||
if (displayMemoryUsage) displayMemoryUsagePostGC();
|
||||
|
||||
// Log that this loop is complete
|
||||
|
@ -1405,8 +1409,8 @@ void performSynchronisedExitProcess(string scopeCaller = null) {
|
|||
shutdownFilesystemMonitor();
|
||||
// Shutdown the database
|
||||
shutdownDatabase();
|
||||
// Shutdown 'curl' instances
|
||||
shutdownCurlInstances();
|
||||
// Destroy all 'curl' instances
|
||||
destroyCurlInstances();
|
||||
// Shutdown the application configuration objects
|
||||
shutdownAppConfig();
|
||||
|
||||
|
@ -1481,8 +1485,8 @@ void shutdownAppConfig() {
|
|||
}
|
||||
}
|
||||
|
||||
void shutdownCurlInstances() {
|
||||
CurlEngine.releaseAllCurlInstances();
|
||||
void destroyCurlInstances() {
|
||||
CurlEngine.destroyAllCurlInstances();
|
||||
}
|
||||
|
||||
void shutdownApplicationLogging() {
|
||||
|
|
19
src/util.d
19
src/util.d
|
@ -202,7 +202,7 @@ Regex!char wild2regex(const(char)[] pattern) {
|
|||
}
|
||||
|
||||
// Test Internet access to Microsoft OneDrive
|
||||
bool testInternetReachability(ApplicationConfig appConfig) {
|
||||
bool testInternetReachabilityCurlPool(ApplicationConfig appConfig) {
|
||||
CurlEngine curlEngine;
|
||||
bool result = false;
|
||||
try {
|
||||
|
@ -240,7 +240,7 @@ bool testInternetReachability(ApplicationConfig appConfig) {
|
|||
}
|
||||
|
||||
// Test Internet access to Microsoft OneDrive using a simple HTTP HEAD request
|
||||
bool testInternetReachabilityAlternate(ApplicationConfig appConfig) {
|
||||
bool testInternetReachability(ApplicationConfig appConfig) {
|
||||
auto http = HTTP();
|
||||
http.url = "https://login.microsoftonline.com";
|
||||
|
||||
|
@ -1114,26 +1114,25 @@ string generateAlphanumericString(size_t length = 16) {
|
|||
void displayMemoryUsagePreGC() {
|
||||
// Display memory usage
|
||||
writeln();
|
||||
writeln("Memory Usage pre GC (KB)");
|
||||
writeln("------------------------");
|
||||
writeln("Memory Usage PRE Garbage Collection (KB)");
|
||||
writeln("-----------------------------------------");
|
||||
writeMemoryStats();
|
||||
writeln();
|
||||
}
|
||||
|
||||
void displayMemoryUsagePostGC() {
|
||||
// Display memory usage
|
||||
writeln();
|
||||
writeln("Memory Usage post GC (KB)");
|
||||
writeln("-------------------------");
|
||||
writeln("Memory Usage POST Garbage Collection (KB)");
|
||||
writeln("-----------------------------------------");
|
||||
writeMemoryStats();
|
||||
writeln();
|
||||
}
|
||||
|
||||
void writeMemoryStats() {
|
||||
// write memory stats
|
||||
writeln("memory usedSize = ", (GC.stats.usedSize/1024));
|
||||
writeln("memory freeSize = ", (GC.stats.freeSize/1024));
|
||||
writeln("memory allocatedInCurrentThread = ", (GC.stats.allocatedInCurrentThread/1024));
|
||||
writeln("memory usedSize = ", (GC.stats.usedSize/1024)); // number of used bytes on the GC heap (might only get updated after a collection)
|
||||
writeln("memory freeSize = ", (GC.stats.freeSize/1024)); // number of free bytes on the GC heap (might only get updated after a collection)
|
||||
writeln("memory allocatedInCurrentThread = ", (GC.stats.allocatedInCurrentThread/1024)); // number of bytes allocated for current thread since program start
|
||||
}
|
||||
|
||||
// Return the username of the UID running the 'onedrive' process
|
||||
|
|
Loading…
Reference in a new issue