summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-06-12 16:51:25 +0000
committerB. Stack <bgstack15@gmail.com>2021-06-12 16:51:25 +0000
commitd22ca0d17503de5733c909764cd54b586b52134f (patch)
treeb8076aea9d6e6408500ea8925ff233c2159a220b
parentMerge branch '11.10' into 'master' (diff)
parentadd upstream 11.11 (diff)
downloadFreeFileSync-d22ca0d17503de5733c909764cd54b586b52134f.tar.gz
FreeFileSync-d22ca0d17503de5733c909764cd54b586b52134f.tar.bz2
FreeFileSync-d22ca0d17503de5733c909764cd54b586b52134f.zip
Merge branch '11.11' into 'master'11.11
add upstream 11.11 See merge request opensource-tracking/FreeFileSync!34
-rw-r--r--Changelog.txt12
-rw-r--r--FreeFileSync/Build/Resources/Languages.zipbin507719 -> 507697 bytes
-rw-r--r--FreeFileSync/Build/Resources/cacert.pem216
-rw-r--r--FreeFileSync/Source/afs/abstract.cpp1
-rw-r--r--FreeFileSync/Source/afs/ftp.cpp12
-rw-r--r--FreeFileSync/Source/afs/gdrive.cpp575
-rw-r--r--FreeFileSync/Source/afs/native.cpp6
-rw-r--r--FreeFileSync/Source/afs/sftp.cpp71
-rw-r--r--FreeFileSync/Source/base/algorithm.cpp38
-rw-r--r--FreeFileSync/Source/base/algorithm.h5
-rw-r--r--FreeFileSync/Source/config.cpp2
-rw-r--r--FreeFileSync/Source/localization.cpp6
-rw-r--r--FreeFileSync/Source/parse_plural.h2
-rw-r--r--FreeFileSync/Source/ui/cfg_grid.cpp1
-rw-r--r--FreeFileSync/Source/ui/main_dlg.cpp73
-rw-r--r--FreeFileSync/Source/ui/main_dlg.h2
-rw-r--r--FreeFileSync/Source/ui/small_dlgs.cpp4
-rw-r--r--FreeFileSync/Source/version/version.h2
-rw-r--r--libcurl/curl_wrap.h5
-rw-r--r--wx+/file_drop.h2
-rw-r--r--zen/file_access.cpp2
-rw-r--r--zen/i18n.h2
-rw-r--r--zen/legacy_compiler.h6
-rw-r--r--zen/string_base.h4
-rw-r--r--zen/string_tools.h3
-rw-r--r--zen/time.h14
26 files changed, 536 insertions, 530 deletions
diff --git a/Changelog.txt b/Changelog.txt
index 6a5be5a8..9102f8a4 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,13 @@
+FreeFileSync 11.11 [2021-06-11]
+-------------------------------
+Fixed Shared Drive synchronization with Google Drive
+Directly open exported file list (.CSV) as temporary file
+Avoid EIO error for F_PREALLOCATE (macOS)
+Watch socket using "poll" instead of "select" (Linux, macOS)
+Fixed user-specific time/date format (Windows)
+Fixed system_profiler not found error (macOS)
+
+
FreeFileSync 11.10 [2021-05-09]
-------------------------------
Fixed comparison results cleared after mouse-scrolling the first folder pair
@@ -6,7 +16,7 @@ Disable all file pairs when base folder status cannot be determined
Fixed sync statistics if base folder existence test failed
Work around glitch in grid scrollbar size calculation
Fixed folder drag and drop failing after locale conflict (macOS)
-Fixed incorrect mime permissions after installation (Linux)
+Fixed incorrect MIME permissions after installation (Linux)
Stricter server response validation during update check
Fixed incomplete item path in log if source item is missing
Fixed installation error when running ConEmu
diff --git a/FreeFileSync/Build/Resources/Languages.zip b/FreeFileSync/Build/Resources/Languages.zip
index 06eedafa..e120e1f2 100644
--- a/FreeFileSync/Build/Resources/Languages.zip
+++ b/FreeFileSync/Build/Resources/Languages.zip
Binary files differ
diff --git a/FreeFileSync/Build/Resources/cacert.pem b/FreeFileSync/Build/Resources/cacert.pem
index 3c79c596..264923b3 100644
--- a/FreeFileSync/Build/Resources/cacert.pem
+++ b/FreeFileSync/Build/Resources/cacert.pem
@@ -1,7 +1,7 @@
##
## Bundle of CA Root Certificates
##
-## Certificate data from Mozilla as of: Tue Jan 19 04:12:04 2021 GMT
+## Certificate data from Mozilla as of: Tue May 25 03:12:05 2021 GMT
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
@@ -14,7 +14,7 @@
## Just configure this file as the SSLCACertificateFile.
##
## Conversion done with mk-ca-bundle.pl version 1.28.
-## SHA256: 3bdc63d1de27058fec943a999a2a8a01fcc6806a611b19221a7727d3d9bbbdfd
+## SHA256: e292bd4e2d500c86df45b830d89417be5c42ee670408f1d2c454c63d8a782865
##
@@ -718,51 +718,6 @@ vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
-----END CERTIFICATE-----
-GeoTrust Primary Certification Authority - G2
-=============================================
------BEGIN CERTIFICATE-----
-MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
-VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
-Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
-ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
-OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
-MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
-b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
-BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
-KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
-VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
-EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
-ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
-npaqBA+K
------END CERTIFICATE-----
-
-VeriSign Universal Root Certification Authority
-===============================================
------BEGIN CERTIFICATE-----
-MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
-BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
-ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
-IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
-IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
-UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
-cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
-IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
-aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
-1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
-MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
-9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
-AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
-tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
-CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
-a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
-DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
-Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
-Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
-P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
-wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
-mJO37M2CYfE45k+XmCpajQ==
------END CERTIFICATE-----
-
NetLock Arany (Class Gold) Főtanúsítvány
========================================
-----BEGIN CERTIFICATE-----
@@ -938,82 +893,6 @@ Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
-----END CERTIFICATE-----
-Chambers of Commerce Root - 2008
-================================
------BEGIN CERTIFICATE-----
-MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
-MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
-bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
-QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
-Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
-ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
-EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
-cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
-AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
-XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
-h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
-ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
-NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm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6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
-M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
-YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
-9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
-zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
-nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
-OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
------END CERTIFICATE-----
-
-Global Chambersign Root - 2008
-==============================
------BEGIN CERTIFICATE-----
-MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
-MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
-bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
-QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
-NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
-Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
-QTgyNzQzMjg3MRswGQYDVQQKExJBQyBD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vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
-aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
-1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
-dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
-/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
-ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
-dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
-9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
-foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
-qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
-P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
-c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
-09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
------END CERTIFICATE-----
-
Go Daddy Root Certificate Authority - G2
========================================
-----BEGIN CERTIFICATE-----
@@ -1980,36 +1859,6 @@ uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
-----END CERTIFICATE-----
-Staat der Nederlanden Root CA - G3
-==================================
------BEGIN CERTIFICATE-----
-MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
-CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
-Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
-TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
-ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
-olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
-x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
-EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
-Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
-mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
-1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
-07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735z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AMDMEYxCzAJBgNVBAYT
+AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg
+RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV
+BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq
+hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB
+jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj
+QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL
+gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk
+vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
+CAezNIm8BZ/3Hobui3A=
+-----END CERTIFICATE-----
diff --git a/FreeFileSync/Source/afs/abstract.cpp b/FreeFileSync/Source/afs/abstract.cpp
index 614f1290..a0d1ab2c 100644
--- a/FreeFileSync/Source/afs/abstract.cpp
+++ b/FreeFileSync/Source/afs/abstract.cpp
@@ -172,7 +172,6 @@ AFS::FileCopyResult AFS::copyFileTransactional(const AbstractPath& apSource, con
const std::function<void()>& onDeleteTargetFile,
const IoCallback& notifyUnbufferedIO /*throw X*/)
{
-
auto copyFilePlain = [&](const AbstractPath& apTargetTmp)
{
//caveat: typeid returns static type for pointers, dynamic type for references!!!
diff --git a/FreeFileSync/Source/afs/ftp.cpp b/FreeFileSync/Source/afs/ftp.cpp
index 55b35829..d9c41e7d 100644
--- a/FreeFileSync/Source/afs/ftp.cpp
+++ b/FreeFileSync/Source/afs/ftp.cpp
@@ -182,7 +182,7 @@ std::vector<std::string> splitFtpResponse(const std::string& buf)
class FtpLineParser
{
public:
- FtpLineParser(const std::string& line) : line_(line), it_(line_.begin()) {}
+ explicit FtpLineParser(const std::string& line) : line_(line), it_(line_.begin()) {}
template <class Function>
std::string readRange(size_t count, Function acceptChar) //throw SysError
@@ -269,14 +269,14 @@ std::wstring formatFtpStatus(int sc)
//================================================================================================================
//================================================================================================================
-constinit2 Global<UniSessionCounter> globalFtpSessionCount;
+constinit Global<UniSessionCounter> globalFtpSessionCount;
GLOBAL_RUN_ONCE(globalFtpSessionCount.set(createUniSessionCounter()));
class FtpSession
{
public:
- FtpSession(const FtpSessionId& sessionId) : //throw SysError
+ explicit FtpSession(const FtpSessionId& sessionId) : //throw SysError
sessionId_(sessionId),
libsshCurlUnifiedInitCookie_(getLibsshCurlUnifiedInitCookie(globalFtpSessionCount)), //throw SysError
lastSuccessfulUseTime_(std::chrono::steady_clock::now()) {}
@@ -738,7 +738,7 @@ private:
{
if (!featureCache_)
{
- static constinit2 FunStatGlobal<Protected<FeatureList>> globalServerFeatures;
+ static constinit FunStatGlobal<Protected<FeatureList>> globalServerFeatures;
globalServerFeatures.initOnce([] { return std::make_unique<Protected<FeatureList>>(); });
const auto sf = globalServerFeatures.get();
@@ -925,7 +925,7 @@ private:
//--------------------------------------------------------------------------------------
UniInitializer globalStartupInitFtp(*globalFtpSessionCount.get());
-constinit2 Global<FtpSessionManager> globalFtpSessionManager; //caveat: life time must be subset of static UniInitializer!
+constinit Global<FtpSessionManager> globalFtpSessionManager; //caveat: life time must be subset of static UniInitializer!
//--------------------------------------------------------------------------------------
void accessFtpSession(const FtpLogin& login, const std::function<void(FtpSession& session)>& useFtpSession /*throw X*/) //throw SysError, X
@@ -1932,7 +1932,7 @@ private:
class FtpFileSystem : public AbstractFileSystem
{
public:
- FtpFileSystem(const FtpLogin& login) : login_(login) {}
+ explicit FtpFileSystem(const FtpLogin& login) : login_(login) {}
const FtpLogin& getLogin() const { return login_; }
diff --git a/FreeFileSync/Source/afs/gdrive.cpp b/FreeFileSync/Source/afs/gdrive.cpp
index 74703ebb..0526c183 100644
--- a/FreeFileSync/Source/afs/gdrive.cpp
+++ b/FreeFileSync/Source/afs/gdrive.cpp
@@ -25,6 +25,7 @@
#include <zen/zlib_wrap.h>
#include "abstract_impl.h"
#include "init_curl_libssh2.h"
+ #include <poll.h>
using namespace zen;
using namespace fff;
@@ -54,7 +55,7 @@ std::weak_ordering operator<=>(const GdriveRawPath& lhs, const GdriveRawPath& rh
return compareNativePath(lhs.itemName, rhs.itemName);
}
-constinit2 Global<PathAccessLocker<GdriveRawPath>> globalGdrivePathAccessLocker;
+constinit Global<PathAccessLocker<GdriveRawPath>> globalGdrivePathAccessLocker;
GLOBAL_RUN_ONCE(globalGdrivePathAccessLocker.set(std::make_unique<PathAccessLocker<GdriveRawPath>>()));
template <> std::shared_ptr<PathAccessLocker<GdriveRawPath>> PathAccessLocker<GdriveRawPath>::getGlobalInstance() { return globalGdrivePathAccessLocker.get(); }
@@ -83,7 +84,7 @@ const char gdriveFolderMimeType [] = "application/vnd.google-apps.folder";
const char gdriveShortcutMimeType[] = "application/vnd.google-apps.shortcut"; //= symbolic link!
const char DB_FILE_DESCR[] = "FreeFileSync";
-const int DB_FILE_VERSION = 4; //2020-07-03
+const int DB_FILE_VERSION = 5; //2021-05-15
std::string getGdriveClientId () { return ""; } // => replace with live credentials
std::string getGdriveClientSecret() { return ""; } //
@@ -179,7 +180,7 @@ AFS::FingerPrint getGdriveFilePrint(const std::string& itemId)
//----------------------------------------------------------------------------------------------------------------
-constinit2 Global<UniSessionCounter> httpSessionCount;
+constinit Global<UniSessionCounter> httpSessionCount;
GLOBAL_RUN_ONCE(httpSessionCount.set(createUniSessionCounter()));
UniInitializer startupInitHttp(*httpSessionCount.get());
@@ -301,7 +302,7 @@ private:
};
//--------------------------------------------------------------------------------------
-constinit2 Global<HttpSessionManager> globalHttpSessionManager; //caveat: life time must be subset of static UniInitializer!
+constinit Global<HttpSessionManager> globalHttpSessionManager; //caveat: life time must be subset of static UniInitializer!
//--------------------------------------------------------------------------------------
@@ -526,18 +527,14 @@ GdriveAccessInfo gdriveAuthorizeAccess(const std::string& gdriveLoginHint, const
{
if (updateGui) updateGui(); //throw X
- fd_set readfds = {}; //covers FD_ZERO
- FD_SET(socket, &readfds);
+ const int waitTimeMs = 100;
+ pollfd fds[] = {{socket, POLLIN}};
- timeval tv = {};
- tv.tv_usec = static_cast<long>(100 /*ms*/) * 1000;
-
- //WSAPoll broken, even ::poll() on OS X? https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
- //perf: no significant difference compared to ::WSAPoll()
- if (const int rc = ::select(socket + 1, &readfds, nullptr /*writefds*/, nullptr /*errorfds*/, &tv);
- rc < 0)
- THROW_LAST_SYS_ERROR_WSA("select");
- else if (rc != 0)
+ const char* functionName = "poll";
+ if (const int rv = ::poll(fds, std::size(fds), waitTimeMs); //int timeout
+ rv < 0)
+ THROW_LAST_SYS_ERROR_WSA(functionName);
+ else if (rv != 0)
break;
//else: time-out!
}
@@ -776,7 +773,7 @@ std::vector<DriveDetails> getSharedDrives(const std::string& accessToken) //thro
{
std::optional<std::string> driveId = getPrimitiveFromJsonObject(driveVal, "id");
std::optional<std::string> driveName = getPrimitiveFromJsonObject(driveVal, "name");
- if (!driveId || !driveName)
+ if (!driveId || !driveName || driveName->empty())
throw SysError(formatGdriveErrorRaw(serializeJson(driveVal)));
sharedDrives.push_back({std::move(*driveId), utfTo<Zstring>(*driveName)});
@@ -1004,23 +1001,28 @@ struct ChangesDelta
std::vector<FileChange> fileChanges;
std::vector<DriveChange> driveChanges;
};
-ChangesDelta getChangesDelta(const std::string& startPageToken, const std::string& accessToken) //throw SysError
+ChangesDelta getChangesDelta(const std::string& sharedDriveId /*empty for "My Drive"*/, const std::string& startPageToken, const std::string& accessToken) //throw SysError
{
//https://developers.google.com/drive/api/v3/reference/changes/list
ChangesDelta delta;
std::optional<std::string> nextPageToken = startPageToken;
for (;;)
{
- const std::string& queryParams = xWwwFormUrlEncode(
+ std::string queryParams = xWwwFormUrlEncode(
{
{"pageToken", *nextPageToken},
{"fields", "kind,nextPageToken,newStartPageToken,changes(kind,changeType,removed,fileId,file(trashed,name,mimeType,ownedByMe,size,modifiedTime,parents,shortcutDetails(targetId)),driveId,drive(name))"},
- {"includeItemsFromAllDrives", "true"},
+ {"includeItemsFromAllDrives", "true"}, //semantics are a mess https://developers.google.com/drive/api/v3/enable-shareddrives https://freefilesync.org/forum/viewtopic.php?t=7827&start=30#p29712
+ //in short: if driveId is set: required, but blatant lie; only drive-specific file changes returned
+ // if no driveId set: optional, but blatant lie; only changes to drive objects are returned, but not contained files (with a few exceptions)
{"pageSize", "1000"}, //"[1, 1000] Default: 100"
{"spaces", "drive"},
{"supportsAllDrives", "true"},
//do NOT "restrictToMyDrive": we're also interested in "Shared with me" items, which might be referenced by a shortcut in "My Drive"
});
+ if (!sharedDriveId.empty())
+ queryParams += '&' + xWwwFormUrlEncode({{"driveId", sharedDriveId}}); //only allowed for shared drives!
+
std::string response;
gdriveHttpsRequest("/drive/v3/changes?" + queryParams, {"Authorization: Bearer " + accessToken}, {} /*extraOptions*/, //throw SysError
[&](const void* buffer, size_t bytesToWrite) { response.append(static_cast<const char*>(buffer), bytesToWrite); }, nullptr /*readRequest*/);
@@ -1104,13 +1106,16 @@ ChangesDelta getChangesDelta(const std::string& startPageToken, const std::strin
}
-std::string /*startPageToken*/ getChangesCurrentToken(const std::string& accessToken) //throw SysError
+std::string /*startPageToken*/ getChangesCurrentToken(const std::string& sharedDriveId /*empty for "My Drive"*/, const std::string& accessToken) //throw SysError
{
//https://developers.google.com/drive/api/v3/reference/changes/getStartPageToken
- const std::string& queryParams = xWwwFormUrlEncode(
+ std::string queryParams = xWwwFormUrlEncode(
{
{"supportsAllDrives", "true"},
});
+ if (!sharedDriveId.empty())
+ queryParams += '&' + xWwwFormUrlEncode({{"driveId", sharedDriveId}}); //only allowed for shared drives!
+
std::string response;
gdriveHttpsRequest("/drive/v3/changes/startPageToken?" + queryParams, {"Authorization: Bearer " + accessToken}, {} /*extraOptions*/, //throw SysError
[&](const void* buffer, size_t bytesToWrite) { response.append(static_cast<const char*>(buffer), bytesToWrite); }, nullptr /*readRequest*/);
@@ -1696,10 +1701,10 @@ std::string /*itemId*/ getMyDriveId(const std::string& accessToken) //throw SysE
}
-class GdriveAccessBuffer //per-user-session! => serialize access (perf: amortized fully buffered!)
+class GdriveAccessBuffer //per-user-session & drive! => serialize access (perf: amortized fully buffered!)
{
public:
- GdriveAccessBuffer(const GdriveAccessInfo& accessInfo) : accessInfo_(accessInfo) {}
+ explicit GdriveAccessBuffer(const GdriveAccessInfo& accessInfo) : accessInfo_(accessInfo) {}
GdriveAccessBuffer(MemoryStreamIn<std::string>& stream) //throw SysError
{
@@ -1747,35 +1752,27 @@ private:
};
-class GdrivePersistentSessions;
+class GdriveDrivesBuffer;
class GdriveFileState //per-user-session! => serialize access (perf: amortized fully buffered!)
{
public:
- GdriveFileState(GdriveAccessBuffer& accessBuf) : //throw SysError
+ GdriveFileState(const std::string& driveId, //ID of shared drive or "My Drive": not empty!
+ const Zstring& sharedDriveName, //*empty* for "My Drive"
+ GdriveAccessBuffer& accessBuf) : //throw SysError
/* issue getChangesCurrentToken() as the very first Google Drive query! */
- lastSyncToken_(getChangesCurrentToken(accessBuf.getAccessToken())), //throw SysError
- myDriveId_ (getMyDriveId (accessBuf.getAccessToken())), //
- accessBuf_(accessBuf)
- {
- for (const DriveDetails& drive : getSharedDrives(accessBuf.getAccessToken())) //throw SysError
- sharedDrives_.emplace(drive.driveId, drive.driveName);
- }
+ lastSyncToken_(getChangesCurrentToken(sharedDriveName.empty() ? std::string() : driveId, accessBuf.getAccessToken())), //throw SysError
+ driveId_(driveId),
+ sharedDriveName_(sharedDriveName),
+ accessBuf_(accessBuf) { assert(sharedDriveName != Zstr("My Drive")); }
GdriveFileState(MemoryStreamIn<std::string>& stream, GdriveAccessBuffer& accessBuf) : //throw SysError
accessBuf_(accessBuf)
{
- lastSyncToken_ = readContainer<std::string>(stream); //SysErrorUnexpectedEos
- myDriveId_ = readContainer<std::string>(stream); //
-
- size_t sharedDrivesCount = readNumber<uint32_t>(stream); //SysErrorUnexpectedEos
- while (sharedDrivesCount-- != 0)
- {
- std::string driveId = readContainer<std::string>(stream); //SysErrorUnexpectedEos
- std::string driveName = readContainer<std::string>(stream); //
- sharedDrives_.emplace(driveId, utfTo<Zstring>(driveName));
- }
+ lastSyncToken_ = readContainer<std::string>(stream); //
+ driveId_ = readContainer<std::string>(stream); //SysErrorUnexpectedEos
+ sharedDriveName_ = utfTo<Zstring>(readContainer<std::string>(stream)); //
for (;;)
{
@@ -1810,14 +1807,8 @@ public:
void serialize(MemoryStreamOut<std::string>& stream) const
{
writeContainer(stream, lastSyncToken_);
- writeContainer(stream, myDriveId_);
-
- writeNumber(stream, static_cast<uint32_t>(sharedDrives_.size()));
- for (const auto& [driveId, driveName]: sharedDrives_)
- {
- writeContainer(stream, driveId);
- writeContainer(stream, utfTo<std::string>(driveName));
- }
+ writeContainer(stream, driveId_);
+ writeContainer(stream, utfTo<std::string>(sharedDriveName_));
for (const auto& [folderId, content] : folderContents_)
if (folderId.empty())
@@ -1865,15 +1856,10 @@ public:
writeContainer(stream, std::string()); //sentinel
}
- std::vector<Zstring /*sharedDriveName*/> listSharedDrives() const
- {
- std::vector<Zstring> sharedDriveNames;
-
- for (const auto& [driveId, driveName]: sharedDrives_)
- sharedDriveNames.push_back(driveName);
+ std::string getDriveId() const { return driveId_; }
- return sharedDriveNames;
- }
+ Zstring getSharedDriveName() const { return sharedDriveName_; }
+ void setSharedDriveName(const Zstring& sharedDriveName) { sharedDriveName_ = sharedDriveName; }
struct PathStatus
{
@@ -1882,76 +1868,42 @@ public:
AfsPath existingPath; //input path =: existingPath + relPath
std::vector<Zstring> relPath; //
};
- PathStatus getPathStatus(const Zstring& sharedDriveName, const AfsPath& afsPath, bool followLeafShortcut) //throw SysError
+ PathStatus getPathStatus(const AfsPath& afsPath, bool followLeafShortcut) //throw SysError
{
- const std::string driveId = [&]
- {
- if (sharedDriveName.empty())
- return myDriveId_;
-
- auto itFound = sharedDrives_.cend();
- for (auto it = sharedDrives_.begin(); it != sharedDrives_.end(); ++it)
- if (const auto& [sharedDriveId, driveName] = *it;
- equalNativePath(driveName, sharedDriveName))
- {
- if (itFound != sharedDrives_.end())
- throw SysError(replaceCpy(_("Cannot find %x."), L"%x",
- fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, AfsPath()}))) + L' ' +
- replaceCpy(_("The name %x is used by more than one item in the folder."), L"%x", fmtPath(sharedDriveName)));
- itFound = it;
- }
- if (itFound == sharedDrives_.end())
- throw SysError(replaceCpy(_("Cannot find %x."), L"%x",
- fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, AfsPath()}))));
-
- return itFound->first;
- }();
-
const std::vector<Zstring> relPath = split(afsPath.value, FILE_NAME_SEPARATOR, SplitOnEmpty::skip);
if (relPath.empty())
- return {driveId, GdriveItemType::folder, AfsPath(), {}};
+ return {driveId_, GdriveItemType::folder, AfsPath(), {}};
else
- return getPathStatusSub(driveId, sharedDriveName, AfsPath(), relPath, followLeafShortcut); //throw SysError
+ return getPathStatusSub(driveId_, AfsPath(), relPath, followLeafShortcut); //throw SysError
}
- std::string /*itemId*/ getItemId(const Zstring& sharedDriveName, const AfsPath& afsPath, bool followLeafShortcut) //throw SysError
+ std::string /*itemId*/ getItemId(const AfsPath& afsPath, bool followLeafShortcut) //throw SysError
{
- const GdriveFileState::PathStatus& ps = getPathStatus(sharedDriveName, afsPath, followLeafShortcut); //throw SysError
+ const GdriveFileState::PathStatus& ps = getPathStatus(afsPath, followLeafShortcut); //throw SysError
if (ps.relPath.empty())
return ps.existingItemId;
const AfsPath afsPathMissingChild(nativeAppendPaths(ps.existingPath.value, ps.relPath.front()));
- throw SysError(replaceCpy(_("Cannot find %x."), L"%x", fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, afsPathMissingChild}))));
+ throw SysError(replaceCpy(_("Cannot find %x."), L"%x", fmtPath(getDisplayPath(afsPathMissingChild))));
}
- std::pair<std::string /*itemId*/, GdriveItemDetails> getFileAttributes(const Zstring& sharedDriveName, const AfsPath& afsPath, bool followLeafShortcut) //throw SysError
+ std::pair<std::string /*itemId*/, GdriveItemDetails> getFileAttributes(const AfsPath& afsPath, bool followLeafShortcut) //throw SysError
{
- const std::string itemId = getItemId(sharedDriveName, afsPath, followLeafShortcut); //throw SysError
+ const std::string itemId = getItemId(afsPath, followLeafShortcut); //throw SysError
if (afsPath.value.empty()) //root drives obviously not covered by itemDetails_
{
GdriveItemDetails rootDetails = {};
rootDetails.type = GdriveItemType::folder;
- if (itemId == myDriveId_)
- {
- rootDetails.itemName = Zstr("My Drive");
- rootDetails.owner = FileOwner::me;
- return {itemId, std::move(rootDetails)};
- }
-
- if (auto it = sharedDrives_.find(itemId);
- it != sharedDrives_.end())
- {
- rootDetails.itemName = it->second;
- rootDetails.owner = FileOwner::none;
- return {itemId, std::move(rootDetails)};
- }
+ //rootDetails.itemName =... => better leave empty for a root item!
+ rootDetails.owner = sharedDriveName_.empty() ? FileOwner::me : FileOwner::none;
+ return {itemId, std::move(rootDetails)};
}
else if (auto it = itemDetails_.find(itemId);
it != itemDetails_.end())
return *it;
- //itemId was found! => must either be a (shared) drive root or buffered in itemDetails_
+ //itemId was found! => must either be a drive root or buffered in itemDetails_
throw std::logic_error("Contract violation! " + std::string(__FILE__) + ':' + numberTo<std::string>(__LINE__));
}
@@ -2082,7 +2034,13 @@ private:
GdriveFileState (const GdriveFileState&) = delete;
GdriveFileState& operator=(const GdriveFileState&) = delete;
- friend class GdrivePersistentSessions;
+ friend class GdriveDrivesBuffer;
+
+ std::wstring getDisplayPath(const AfsPath& afsPath) const
+ {
+ const GdriveLogin login{accessBuf_.getUserEmail(), sharedDriveName_};
+ return getGdriveDisplayPath({login, afsPath});
+ }
void notifyItemUpdated(const FileStateDelta& stateDelta, const std::string& itemId, const GdriveItemDetails* details)
{
@@ -2112,14 +2070,11 @@ private:
void syncWithGoogle() //throw SysError
{
- const ChangesDelta delta = getChangesDelta(lastSyncToken_, accessBuf_.getAccessToken()); //throw SysError
+ const ChangesDelta delta = getChangesDelta(sharedDriveName_.empty() ? std::string() : driveId_, lastSyncToken_, accessBuf_.getAccessToken()); //throw SysError
for (const FileChange& change : delta.fileChanges)
updateItemState(change.itemId, get(change.details));
- for (const DriveChange& change : delta.driveChanges)
- updateSharedDriveState(change.driveId, change.driveName);
-
lastSyncToken_ = delta.newStartPageToken;
lastSyncTime_ = std::chrono::steady_clock::now();
@@ -2127,7 +2082,7 @@ private:
//Same goes for any other change that is undone in between change notification syncs.
}
- PathStatus getPathStatusSub(const std::string& folderId, const Zstring& sharedDriveName, const AfsPath& folderPath, const std::vector<Zstring>& relPath, bool followLeafShortcut) //throw SysError
+ PathStatus getPathStatusSub(const std::string& folderId, const AfsPath& folderPath, const std::vector<Zstring>& relPath, bool followLeafShortcut) //throw SysError
{
assert(!relPath.empty());
@@ -2144,13 +2099,13 @@ private:
auto itFound = itemDetails_.cend();
for (const DetailsIterator& itChild : itKnown->second.childItems)
- //Since Google Drive has no concept of a file path, we have to roll our own "path to id" mapping => let's use the platform-native style
+ //Since Google Drive has no concept of a file path, we have to roll our own "path to ID" mapping => let's use the platform-native style
if (equalNativePath(itChild->second.itemName, relPath.front()))
{
if (itFound != itemDetails_.end())
throw SysError(replaceCpy(_("Cannot find %x."), L"%x",
- fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, AfsPath(nativeAppendPaths(folderPath.value, relPath.front()))}))) + L' ' +
- replaceCpy(_("The name %x is used by more than one item in the folder."), L"%x", fmtPath(relPath.front())));
+ fmtPath(getDisplayPath(AfsPath(nativeAppendPaths(folderPath.value, relPath.front()))))) + L' ' +
+ replaceCpy(_("The name %x is used by more than one item in the folder."), L"%x", fmtPath(relPath.front())));
itFound = itChild;
}
@@ -2190,7 +2145,7 @@ private:
return {childId, childDetails.type, childItemPath, childRelPath};
case GdriveItemType::folder:
- return getPathStatusSub(childId, sharedDriveName, childItemPath, childRelPath, followLeafShortcut); //throw SysError
+ return getPathStatusSub(childId, childItemPath, childRelPath, followLeafShortcut); //throw SysError
case GdriveItemType::shortcut:
switch (getItemDetailsBuffered(childDetails.targetId).type)
@@ -2199,12 +2154,12 @@ private:
return {childDetails.targetId, GdriveItemType::file, childItemPath, childRelPath}; //resolve symlinks if in the *middle* of a path!
case GdriveItemType::folder: //parent/folder-symlink/child-rel-path... => always follow
- return getPathStatusSub(childDetails.targetId, sharedDriveName, childItemPath, childRelPath, followLeafShortcut); //throw SysError
+ return getPathStatusSub(childDetails.targetId, childItemPath, childRelPath, followLeafShortcut); //throw SysError
case GdriveItemType::shortcut: //should never happen: creating shortcuts to shortcuts fails with "Internal Error"
throw SysError(replaceCpy(_("Cannot resolve symbolic link %x."), L"%x",
- fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, AfsPath(nativeAppendPaths(folderPath.value, relPath.front()))}))) + L' ' +
- L"Google Drive Shortcut points to another Shortcut.");
+ fmtPath(getDisplayPath(AfsPath(nativeAppendPaths(folderPath.value, relPath.front()))))) + L' ' +
+ L"Google Drive Shortcut points to another Shortcut.");
}
break;
}
@@ -2274,62 +2229,174 @@ private:
itemDetails_.erase(it);
}
- if (auto itP = folderContents_.find(itemId);
- itP != folderContents_.end())
+ if (auto itP = folderContents_.find(itemId); itP != folderContents_.end())
{
- for (auto itChild : itP->second.childItems) //2. delete as parent from child items (don't wait for change notifications of children)
+ //2. delete as parent from child items (don't wait for change notifications of children)
+ // what if e.g. single change notification "folder removed", then folder reapears,
+ // and no notifications for child items: possible with Google drive!?
+ // => no problem: FolderContent::isKnownFolder will be false for this restored folder => only a rescan needed
+ for (auto itChild : itP->second.childItems)
std::erase_if(itChild->second.parentIds, [&](const std::string& id) { return id == itemId; });
folderContents_.erase(itP);
}
}
}
- void updateSharedDriveState(const std::string& driveId, const Zstring& driveName /*empty if shared drive was deleted*/)
- {
- if (!driveName.empty())
- sharedDrives_[driveId] = driveName;
- else //delete
- {
- sharedDrives_.erase(driveId);
-
- //when a shared drive is deleted, we also receive change notifications for the contained files: nice!
- if (auto itP = folderContents_.find(driveId);
- itP != folderContents_.end())
- {
- for (auto itChild : itP->second.childItems) //delete as parent from child items (don't wait for change notifications of children)
- std::erase_if(itChild->second.parentIds, [&](const std::string& id) { return id == driveId; });
- folderContents_.erase(itP);
- }
- }
- }
-
using DetailsIterator = std::unordered_map<std::string, GdriveItemDetails>::iterator;
struct FolderContent
{
- bool isKnownFolder = false; //=we've seen its full content at least once; further changes are calculated via change notifications!
+ bool isKnownFolder = false; //:= we've seen its full content at least once; further changes are calculated via change notifications
std::vector<DetailsIterator> childItems;
};
std::unordered_map<std::string /*folderId*/, FolderContent> folderContents_;
std::unordered_map<std::string /*itemId*/, GdriveItemDetails> itemDetails_; //contains ALL known, existing items!
- std::string lastSyncToken_; //marker corresponding to last sync with Google's change notifications
+ std::string lastSyncToken_; //drive-specific(!) marker corresponding to last sync with Google's change notifications
std::chrono::steady_clock::time_point lastSyncTime_ = std::chrono::steady_clock::now() - GDRIVE_SYNC_INTERVAL; //... with Google Drive (default: sync is due)
std::vector<std::weak_ptr<ItemIdDelta>> changeLog_; //track changed items since FileStateDelta was created (includes sync with Google + our own intermediate change notifications)
- std::string myDriveId_;
- std::unordered_map<std::string /*driveId*/, Zstring /*driveName*/> sharedDrives_;
+ std::string driveId_; //ID of shared drive or "My Drive": not empty!
+ Zstring sharedDriveName_; //name of shared drive: empty for "My Drive"!
+
GdriveAccessBuffer& accessBuf_;
};
+
+class GdriveDrivesBuffer
+{
+public:
+ explicit GdriveDrivesBuffer(GdriveAccessBuffer& accessBuf) :
+ accessBuf_(accessBuf),
+ myDrive_(getMyDriveId(accessBuf.getAccessToken()), Zstring() /*sharedDriveName*/, accessBuf) {} //throw SysError
+
+ GdriveDrivesBuffer(MemoryStreamIn<std::string>& stream, GdriveAccessBuffer& accessBuf) : //throw SysError
+ accessBuf_(accessBuf),
+ myDrive_(stream, accessBuf) //throw SysError
+ {
+ size_t sharedDrivesCount = readNumber<uint32_t>(stream); //SysErrorUnexpectedEos
+ while (sharedDrivesCount-- != 0)
+ {
+ auto fileState = makeSharedRef<GdriveFileState>(stream, accessBuf); //throw SysError
+ sharedDrives_.emplace(fileState.ref().getDriveId(), fileState);
+ }
+ }
+
+ void serialize(MemoryStreamOut<std::string>& stream) const
+ {
+ myDrive_.serialize(stream);
+
+ writeNumber(stream, static_cast<uint32_t>(sharedDrives_.size()));
+ for (const auto& [driveId, fileState] : sharedDrives_)
+ fileState.ref().serialize(stream);
+ }
+
+ std::vector<Zstring /*sharedDriveName*/> listSharedDrives() //throw SysError
+ {
+ if (syncIsDue())
+ syncWithGoogle(); //throw SysError
+
+ std::vector<Zstring> sharedDriveNames;
+
+ for (const auto& [driveId, fileState] : sharedDrives_)
+ sharedDriveNames.push_back(fileState.ref().getSharedDriveName());
+
+ return sharedDriveNames;
+ }
+
+ std::pair<GdriveFileState*, GdriveFileState::FileStateDelta> prepareAccess(const Zstring& sharedDriveName) //throw SysError
+ {
+ //checking for added/renamed/deleted shared drives *every* GDRIVE_SYNC_INTERVAL is needlessly excessive!
+ // => check 1. once per FFS run
+ // 2. on drive access error
+ if (lastSyncTime_ == std::chrono::steady_clock::time_point())
+ syncWithGoogle(); //throw SysError
+
+ GdriveFileState* fileState = nullptr;
+ try
+ {
+ fileState = &getDrive(sharedDriveName); //throw SysError
+ }
+ catch (SysError&)
+ {
+ if (syncIsDue())
+ syncWithGoogle(); //throw SysError
+
+ fileState = &getDrive(sharedDriveName); //throw SysError
+ }
+
+ //manage last sync time here so that "lastSyncToken" remains stable while accessing GdriveFileState in the callback
+ if (fileState->syncIsDue())
+ fileState->syncWithGoogle(); //throw SysError
+
+ return {fileState, fileState->registerFileStateDelta()};
+ }
+
+private:
+ bool syncIsDue() const { return std::chrono::steady_clock::now() >= lastSyncTime_ + GDRIVE_SYNC_INTERVAL; }
+
+ void syncWithGoogle() //throw SysError
+ {
+ decltype(sharedDrives_) currentDrives;
+
+ //getSharedDrives() should be fast enough to avoid the unjustified complexity of change notifications: https://freefilesync.org/forum/viewtopic.php?t=7827&start=30#p29712
+ for (const auto& [driveId, driveName] : getSharedDrives(accessBuf_.getAccessToken())) //throw SysError
+ {
+ auto fileState = [&, &driveId /*clang bug*/= driveId, &driveName /*clang bug*/= driveName]
+ {
+ if (auto it = sharedDrives_.find(driveId);
+ it != sharedDrives_.end())
+ {
+ it->second.ref().setSharedDriveName(driveName);
+ return it->second;
+ }
+ else
+ return makeSharedRef<GdriveFileState>(driveId, driveName, accessBuf_); //throw SysError
+ }();
+ currentDrives.emplace(driveId, fileState);
+ }
+
+ sharedDrives_.swap(currentDrives); //transaction!
+ lastSyncTime_ = std::chrono::steady_clock::now(); //...(uhm, mostly, except for setSharedDriveName())
+ }
+
+ GdriveFileState& getDrive(const Zstring& sharedDriveName) //throw SysError
+ {
+ if (sharedDriveName.empty())
+ return myDrive_;
+
+ auto itFound = sharedDrives_.end();
+ for (auto it = sharedDrives_.begin(); it != sharedDrives_.end(); ++it)
+ if (equalNativePath(it->second.ref().getSharedDriveName(), sharedDriveName))
+ {
+ if (itFound != sharedDrives_.end())
+ throw SysError(replaceCpy(_("Cannot find %x."), L"%x",
+ fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, AfsPath()}))) + L' ' +
+ replaceCpy(_("The name %x is used by more than one item in the folder."), L"%x", fmtPath(sharedDriveName)));
+ itFound = it;
+ }
+ if (itFound == sharedDrives_.end())
+ throw SysError(replaceCpy(_("Cannot find %x."), L"%x",
+ fmtPath(getGdriveDisplayPath({{accessBuf_.getUserEmail(), sharedDriveName}, AfsPath()}))));
+
+ return itFound->second.ref();
+ }
+
+ GdriveAccessBuffer& accessBuf_;
+ std::chrono::steady_clock::time_point lastSyncTime_; //... with Google Drive (default: sync is due)
+
+ GdriveFileState myDrive_;
+ std::unordered_map<std::string /*drive ID*/, SharedRef<GdriveFileState>> sharedDrives_;
+};
+
//==========================================================================================
//==========================================================================================
class GdrivePersistentSessions
{
public:
- GdrivePersistentSessions(const Zstring& configDirPath) : configDirPath_(configDirPath) {}
+ explicit GdrivePersistentSessions(const Zstring& configDirPath) : configDirPath_(configDirPath) {}
void saveActiveSessions() //throw FileError
{
@@ -2375,8 +2442,8 @@ public:
else
{
auto accessBuf = makeSharedRef<GdriveAccessBuffer>(accessInfo);
- auto fileState = makeSharedRef<GdriveFileState >(accessBuf.ref()); //throw SysError
- userSession = {accessBuf, fileState};
+ auto drivesBuf = makeSharedRef<GdriveDrivesBuffer>(accessBuf.ref()); //throw SysError
+ userSession = {accessBuf, drivesBuf};
}
});
@@ -2394,7 +2461,7 @@ public:
});
}
catch (SysError&) { assert(false); } //best effort: try to invalidate the access token
- //=> expected to fail if offline => not worse than removing FFS via "Uninstall Programs"
+ //=> expected to fail 1. if offline => not worse than removing FFS via "Uninstall Programs" 2. already revoked 3. if DB is corrupted
try
{
@@ -2457,30 +2524,41 @@ public:
return emails;
}
+ std::vector<Zstring /*sharedDriveName*/> listSharedDrives(const std::string& accountEmail) //throw SysError
+ {
+ std::vector<Zstring> sharedDriveNames;
+
+ accessUserSession(accountEmail, [&](std::optional<UserSession>& userSession) //throw SysError
+ {
+ if (!userSession)
+ throw SysError(replaceCpy(_("Please authorize access to user account %x."), L"%x", utfTo<std::wstring>(accountEmail)));
+
+ sharedDriveNames = userSession->drivesBuf.ref().listSharedDrives(); //throw SysError
+ });
+ return sharedDriveNames;
+ }
+
struct AsyncAccessInfo
{
std::string accessToken; //don't allow (long-running) web requests while holding the global session lock!
GdriveFileState::FileStateDelta stateDelta;
};
//perf: amortized fully buffered!
- AsyncAccessInfo accessGlobalFileState(const std::string& accountEmail, const std::function<void(GdriveFileState& fileState)>& useFileState /*throw X*/) //throw SysError, X
+ AsyncAccessInfo accessGlobalFileState(const GdriveLogin& login, const std::function<void(GdriveFileState& fileState)>& useFileState /*throw X*/) //throw SysError, X
{
std::string accessToken;
GdriveFileState::FileStateDelta stateDelta;
- accessUserSession(accountEmail, [&](std::optional<UserSession>& userSession) //throw SysError
+ accessUserSession(login.email, [&](std::optional<UserSession>& userSession) //throw SysError
{
if (!userSession)
- throw SysError(replaceCpy(_("Please authorize access to user account %x."), L"%x", utfTo<std::wstring>(accountEmail)));
+ throw SysError(replaceCpy(_("Please authorize access to user account %x."), L"%x", utfTo<std::wstring>(login.email)));
- //manage last sync time here rather than in GdriveFileState, so that "lastSyncToken" remains stable while accessing GdriveFileState in the callback
- if (userSession->fileState.ref().syncIsDue())
- userSession->fileState.ref().syncWithGoogle(); //throw SysError
+ GdriveFileState* fileState = nullptr;
+ accessToken = userSession->accessBuf.ref().getAccessToken(); //throw SysError
+ std::tie(fileState, stateDelta) = userSession->drivesBuf.ref().prepareAccess(login.sharedDriveName); //throw SysError
- accessToken = userSession->accessBuf.ref().getAccessToken(); //throw SysError
- stateDelta = userSession->fileState.ref().registerFileStateDelta();
-
- useFileState(userSession->fileState.ref()); //throw X
+ useFileState(*fileState); //throw X
});
return {accessToken, stateDelta};
}
@@ -2525,7 +2603,7 @@ private:
MemoryStreamOut<std::string> streamOutBody;
userSession.accessBuf.ref().serialize(streamOutBody);
- userSession.fileState.ref().serialize(streamOutBody);
+ userSession.drivesBuf.ref().serialize(streamOutBody);
try
{
@@ -2576,14 +2654,11 @@ private:
version != 3) //TODO: remove migration code at some time! 2020-07-03
throw SysError(_("Unsupported data format.") + L' ' + replaceCpy(_("Version: %x"), L"%x", numberTo<std::wstring>(version)));
+ //version 1 + 2: fully discard old state due to missing "ownedByMe" attribute + shortcut support
+ //version 3: fully discard old state due to revamped shared drive handling
auto accessBuf = makeSharedRef<GdriveAccessBuffer>(streamIn2); //throw SysError
- auto fileState =
- //TODO: remove migration code at some time! 2020-06-11
- version <= 2 ? //fully discard old state due to missing "ownedByMe" attribute + shortcut support
- makeSharedRef<GdriveFileState>( accessBuf.ref()) : //throw SysError
- makeSharedRef<GdriveFileState>(streamIn2, accessBuf.ref()); //
-
- return UserSession{accessBuf, fileState};
+ auto drivesBuf = makeSharedRef<GdriveDrivesBuffer>(accessBuf.ref()); //throw SysError
+ return UserSession{accessBuf, drivesBuf};
}
else
{
@@ -2591,15 +2666,22 @@ private:
throw SysError(_("File content is corrupted.") + L" (invalid header)");
const int version = readNumber<int32_t>(streamIn);
- if (version != DB_FILE_VERSION)
+ if (version != 4 &&
+ version != DB_FILE_VERSION)
throw SysError(_("Unsupported data format.") + L' ' + replaceCpy(_("Version: %x"), L"%x", numberTo<std::wstring>(version)));
MemoryStreamIn streamInBody(decompress(std::string(byteStream.begin() + streamIn.pos(), byteStream.end()))); //throw SysError
auto accessBuf = makeSharedRef<GdriveAccessBuffer>(streamInBody); //throw SysError
- auto fileState = makeSharedRef<GdriveFileState >(streamInBody, accessBuf.ref()); //throw SysError
-
- return UserSession{accessBuf, fileState};
+ auto drivesBuf = [&]
+ {
+ //TODO: remove migration code at some time! 2021-05-15
+ if (version <= 4) //fully discard old state due to revamped shared drive handling
+ return makeSharedRef<GdriveDrivesBuffer>(accessBuf.ref()); //throw SysError
+ else
+ return makeSharedRef<GdriveDrivesBuffer>(streamInBody, accessBuf.ref()); //throw SysError
+ }();
+ return UserSession{accessBuf, drivesBuf};
}
}
catch (const SysError& e)
@@ -2611,7 +2693,7 @@ private:
struct UserSession
{
SharedRef<GdriveAccessBuffer> accessBuf;
- SharedRef<GdriveFileState> fileState;
+ SharedRef<GdriveDrivesBuffer> drivesBuf;
};
struct SessionHolder
@@ -2625,13 +2707,13 @@ private:
const Zstring configDirPath_;
};
//==========================================================================================
-constinit2 Global<GdrivePersistentSessions> globalGdriveSessions;
+constinit Global<GdrivePersistentSessions> globalGdriveSessions;
//==========================================================================================
-GdrivePersistentSessions::AsyncAccessInfo accessGlobalFileState(const std::string& accountEmail, const std::function<void(GdriveFileState& fileState)>& useFileState /*throw X*/) //throw SysError, X
+GdrivePersistentSessions::AsyncAccessInfo accessGlobalFileState(const GdriveLogin& login, const std::function<void(GdriveFileState& fileState)>& useFileState /*throw X*/) //throw SysError, X
{
if (const std::shared_ptr<GdrivePersistentSessions> gps = globalGdriveSessions.get())
- return gps->accessGlobalFileState(accountEmail, useFileState); //throw SysError, X
+ return gps->accessGlobalFileState(login, useFileState); //throw SysError, X
throw SysError(formatSystemError("accessGlobalFileState", L"", L"Function call not allowed during init/shutdown."));
}
@@ -2654,9 +2736,9 @@ struct GetDirDetails
{
std::string folderId;
std::optional<std::vector<GdriveItem>> childItemsBuf;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(folderPath_.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(folderPath_.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
- const auto& [itemId, itemDetails] = fileState.getFileAttributes(folderPath_.gdriveLogin.sharedDriveName, folderPath_.itemPath, true /*followLeafShortcut*/); //throw SysError
+ const auto& [itemId, itemDetails] = fileState.getFileAttributes(folderPath_.itemPath, true /*followLeafShortcut*/); //throw SysError
if (itemDetails.type != GdriveItemType::folder) //check(!) or readFolderContent() will return empty (without failing!)
throw SysError(replaceCpy<std::wstring>(L"%x is not a directory.", L"%x", fmtPath(utfTo<Zstring>(itemDetails.itemName))));
@@ -2670,7 +2752,7 @@ struct GetDirDetails
childItemsBuf = readFolderContent(folderId, aai.accessToken); //throw SysError
//buffer new file state ASAP => make sure accessGlobalFileState() has amortized constant access (despite the occasional internal readFolderContent() on non-leaf folders)
- accessGlobalFileState(folderPath_.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(folderPath_.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyFolderContent(aai.stateDelta, folderId, *childItemsBuf);
});
@@ -2705,7 +2787,7 @@ struct GetShortcutTargetDetails
try
{
std::optional<GdriveItemDetails> targetDetailsBuf;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(shortcutPath_.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(shortcutPath_.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
targetDetailsBuf = fileState.tryGetBufferedItemDetails(shortcutDetails_.targetId);
});
@@ -2714,7 +2796,7 @@ struct GetShortcutTargetDetails
targetDetailsBuf = getItemDetails(shortcutDetails_.targetId, aai.accessToken); //throw SysError
//buffer new file state ASAP
- accessGlobalFileState(shortcutPath_.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(shortcutPath_.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyItemUpdated(aai.stateDelta, {shortcutDetails_.targetId, *targetDetailsBuf});
});
@@ -2839,9 +2921,9 @@ struct InputStreamGdrive : public AFS::InputStream
std::string fileId;
try
{
- accessToken = accessGlobalFileState(gdrivePath.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ accessToken = accessGlobalFileState(gdrivePath.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
- fileId = fileState.getItemId(gdrivePath.gdriveLogin.sharedDriveName, gdrivePath.itemPath, true /*followLeafShortcut*/); //throw SysError
+ fileId = fileState.getItemId(gdrivePath.itemPath, true /*followLeafShortcut*/); //throw SysError
}).accessToken;
}
catch (const SysError& e) { throw FileError(replaceCpy(_("Cannot open file %x."), L"%x", fmtPath(getGdriveDisplayPath(gdrivePath))), e.toString()); }
@@ -2883,9 +2965,9 @@ struct InputStreamGdrive : public AFS::InputStream
AFS::StreamAttributes attr = {};
try
{
- accessGlobalFileState(gdrivePath_.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdrivePath_.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
- const auto& [itemId, itemDetails] = fileState.getFileAttributes(gdrivePath_.gdriveLogin.sharedDriveName, gdrivePath_.itemPath, true /*followLeafShortcut*/); //throw SysError
+ const auto& [itemId, itemDetails] = fileState.getFileAttributes(gdrivePath_.itemPath, true /*followLeafShortcut*/); //throw SysError
attr.modTime = itemDetails.modTime;
attr.fileSize = itemDetails.fileSize;
attr.filePrint = getGdriveFilePrint(itemId);
@@ -2929,15 +3011,15 @@ struct OutputStreamGdrive : public AFS::OutputStreamImpl
// otherwise ~OutputStreamImpl() will delete the already existing file! => don't check asynchronously!
const Zstring fileName = AFS::getItemName(gdrivePath.itemPath);
std::string parentId;
- /*const*/ GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdrivePath.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ /*const*/ GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdrivePath.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
- const GdriveFileState::PathStatus& ps = fileState.getPathStatus(gdrivePath.gdriveLogin.sharedDriveName, gdrivePath.itemPath, false /*followLeafShortcut*/); //throw SysError
+ const GdriveFileState::PathStatus& ps = fileState.getPathStatus(gdrivePath.itemPath, false /*followLeafShortcut*/); //throw SysError
if (ps.relPath.empty())
throw SysError(replaceCpy(_("The name %x is already used by another item."), L"%x", fmtPath(fileName)));
if (ps.relPath.size() > 1) //parent folder missing
throw SysError(replaceCpy(_("Cannot find %x."), L"%x",
- fmtPath(getGdriveDisplayPath({ gdrivePath.gdriveLogin, AfsPath(nativeAppendPaths(ps.existingPath.value, ps.relPath.front()))}))));
+ fmtPath(getGdriveDisplayPath({gdrivePath.gdriveLogin, AfsPath(nativeAppendPaths(ps.existingPath.value, ps.relPath.front()))}))));
parentId = ps.existingItemId;
});
@@ -2975,7 +3057,7 @@ struct OutputStreamGdrive : public AFS::OutputStreamImpl
newFileItem.details.modTime = *modTime;
newFileItem.details.parentIds.push_back(parentId);
- accessGlobalFileState(gdrivePath.gdriveLogin.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdrivePath.gdriveLogin, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyItemCreated(aai.stateDelta, newFileItem);
});
@@ -3051,9 +3133,9 @@ public:
try
{
GdriveFileState::PathStatus ps;
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- ps = fileState.getPathStatus(gdriveLogin_.sharedDriveName, folderPath, true /*followLeafShortcut*/); //throw SysError
+ ps = fileState.getPathStatus(folderPath, true /*followLeafShortcut*/); //throw SysError
});
if (!ps.relPath.empty())
@@ -3077,9 +3159,9 @@ private:
throw SysError(L"Item is device root");
std::string parentId;
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- parentId = fileState.getItemId(gdriveLogin_.sharedDriveName, *parentPath, true /*followLeafShortcut*/); //throw SysError
+ parentId = fileState.getItemId(*parentPath, true /*followLeafShortcut*/); //throw SysError
});
return { std::move(parentId), getItemName(afsPath)};
}
@@ -3115,9 +3197,9 @@ private:
try
{
GdriveFileState::PathStatus ps;
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- ps = fileState.getPathStatus(gdriveLogin_.sharedDriveName, afsPath, false /*followLeafShortcut*/); //throw SysError
+ ps = fileState.getPathStatus(afsPath, false /*followLeafShortcut*/); //throw SysError
});
if (ps.relPath.empty())
switch (ps.existingType)
@@ -3144,9 +3226,9 @@ private:
const Zstring folderName = getItemName(afsPath);
std::string parentId;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- const GdriveFileState::PathStatus& ps = fileState.getPathStatus(gdriveLogin_.sharedDriveName, afsPath, false /*followLeafShortcut*/); //throw SysError
+ const GdriveFileState::PathStatus& ps = fileState.getPathStatus(afsPath, false /*followLeafShortcut*/); //throw SysError
if (ps.relPath.empty())
throw SysError(replaceCpy(_("The name %x is already used by another item."), L"%x", fmtPath(folderName)));
@@ -3159,7 +3241,7 @@ private:
const std::string folderIdNew = gdriveCreateFolderPlain(folderName, parentId, aai.accessToken); //throw SysError
//buffer new file state ASAP (don't wait GDRIVE_SYNC_INTERVAL)
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyFolderCreated(aai.stateDelta, folderIdNew, folderName, parentId);
});
@@ -3171,18 +3253,18 @@ private:
{
std::string itemId;
std::optional<std::string> parentIdToUnlink;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
const std::optional<AfsPath> parentPath = getParentPath(afsPath);
if (!parentPath) throw SysError(L"Item is device root");
GdriveItemDetails itemDetails;
- std::tie(itemId, itemDetails) = fileState.getFileAttributes(gdriveLogin_.sharedDriveName, afsPath, false /*followLeafShortcut*/); //throw SysError
- assert(std::find(itemDetails.parentIds.begin(), itemDetails.parentIds.end(), fileState.getItemId(gdriveLogin_.sharedDriveName, *parentPath, true /*followLeafShortcut*/)) != itemDetails.parentIds.end());
+ std::tie(itemId, itemDetails) = fileState.getFileAttributes(afsPath, false /*followLeafShortcut*/); //throw SysError
+ assert(std::find(itemDetails.parentIds.begin(), itemDetails.parentIds.end(), fileState.getItemId(*parentPath, true /*followLeafShortcut*/)) != itemDetails.parentIds.end());
//hard-link handling applies to shared files as well: 1. it's the right thing (TM) 2. if we're not the owner: deleting would fail
if (itemDetails.parentIds.size() > 1 || itemDetails.owner == FileOwner::other) //FileOwner::other behaves like a followed symlink! i.e. vanishes if owner deletes it!
- parentIdToUnlink = fileState.getItemId(gdriveLogin_.sharedDriveName, *parentPath, true /*followLeafShortcut*/); //throw SysError
+ parentIdToUnlink = fileState.getItemId(*parentPath, true /*followLeafShortcut*/); //throw SysError
});
if (parentIdToUnlink)
@@ -3190,7 +3272,7 @@ private:
gdriveUnlinkParent(itemId, *parentIdToUnlink, aai.accessToken); //throw SysError
//buffer new file state ASAP (don't wait GDRIVE_SYNC_INTERVAL)
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyParentRemoved(aai.stateDelta, itemId, *parentIdToUnlink);
});
@@ -3203,7 +3285,7 @@ private:
gdriveMoveToTrash(itemId, aai.accessToken); //throw SysError
//buffer new file state ASAP (don't wait GDRIVE_SYNC_INTERVAL)
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyItemDeleted(aai.stateDelta, itemId);
});
@@ -3260,9 +3342,9 @@ private:
try
{
std::string targetId;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveFs.gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveFs.gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- const GdriveItemDetails& itemDetails = fileState.getFileAttributes(gdriveFs.gdriveLogin_.sharedDriveName, afsPath, false /*followLeafShortcut*/).second; //throw SysError
+ const GdriveItemDetails& itemDetails = fileState.getFileAttributes(afsPath, false /*followLeafShortcut*/).second; //throw SysError
if (itemDetails.type != GdriveItemType::shortcut)
throw SysError(L"Not a Google Drive Shortcut.");
@@ -3338,21 +3420,20 @@ private:
const Zstring itemNameNew = getItemName(apTarget);
std::string itemIdSrc;
- time_t modTime = 0;
- uint64_t fileSize = 0;
- std::string parentIdTrg;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ GdriveItemDetails itemDetailsSrc;
+ /*const GdrivePersistentSessions::AsyncAccessInfo aaiSrc =*/ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- GdriveItemDetails itemDetails;
- std::tie(itemIdSrc, itemDetails) = fileState.getFileAttributes(gdriveLogin_.sharedDriveName, afsSource, true /*followLeafShortcut*/); //throw SysError
- modTime = itemDetails.modTime;
- fileSize = itemDetails.fileSize;
+ std::tie(itemIdSrc, itemDetailsSrc) = fileState.getFileAttributes(afsSource, true /*followLeafShortcut*/); //throw SysError
- assert(itemDetails.type == GdriveItemType::file); //Google Drive *should* fail trying to copy folder: "This file cannot be copied by the user."
- if (itemDetails.type != GdriveItemType::file) //=> don't trust + improve error message
+ assert(itemDetailsSrc.type == GdriveItemType::file); //Google Drive *should* fail trying to copy folder: "This file cannot be copied by the user."
+ if (itemDetailsSrc.type != GdriveItemType::file) //=> don't trust + improve error message
throw SysError(replaceCpy<std::wstring>(L"%x is not a file.", L"%x", fmtPath(getItemName(afsSource))));
+ });
- const GdriveFileState::PathStatus psTo = fileState.getPathStatus(fsTarget.gdriveLogin_.sharedDriveName, apTarget.afsPath, false /*followLeafShortcut*/); //throw SysError
+ std::string parentIdTrg;
+ const GdrivePersistentSessions::AsyncAccessInfo aaiTrg = accessGlobalFileState(fsTarget.gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
+ {
+ const GdriveFileState::PathStatus psTo = fileState.getPathStatus(apTarget.afsPath, false /*followLeafShortcut*/); //throw SysError
if (psTo.relPath.empty())
throw SysError(replaceCpy(_("The name %x is already used by another item."), L"%x", fmtPath(itemNameNew)));
@@ -3363,25 +3444,25 @@ private:
});
//already existing: creates duplicate
- const std::string fileIdTrg = gdriveCopyFile(itemIdSrc, parentIdTrg, itemNameNew, modTime, aai.accessToken); //throw SysError
+ const std::string fileIdTrg = gdriveCopyFile(itemIdSrc, parentIdTrg, itemNameNew, itemDetailsSrc.modTime, aaiTrg.accessToken); //throw SysError
//buffer new file state ASAP (don't wait GDRIVE_SYNC_INTERVAL)
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(fsTarget.gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
GdriveItem newFileItem = {};
newFileItem.itemId = fileIdTrg;
newFileItem.details.itemName = itemNameNew;
newFileItem.details.type = GdriveItemType::file;
- newFileItem.details.owner = FileOwner::me;
- newFileItem.details.fileSize = fileSize;
- newFileItem.details.modTime = modTime;
+ newFileItem.details.owner = fsTarget.gdriveLogin_.sharedDriveName.empty() ? FileOwner::me : FileOwner::none;
+ newFileItem.details.fileSize = itemDetailsSrc.fileSize;
+ newFileItem.details.modTime = itemDetailsSrc.modTime;
newFileItem.details.parentIds.push_back(parentIdTrg);
- fileState.notifyItemCreated(aai.stateDelta, newFileItem);
+ fileState.notifyItemCreated(aaiTrg.stateDelta, newFileItem);
});
FileCopyResult result;
- result.fileSize = fileSize;
- result.modTime = modTime;
+ result.fileSize = itemDetailsSrc.fileSize;
+ result.modTime = itemDetailsSrc.modTime;
result.sourceFilePrint = getGdriveFilePrint(itemIdSrc);
result.targetFilePrint = getGdriveFilePrint(fileIdTrg);
/*result.errorModTime = */
@@ -3412,9 +3493,9 @@ private:
try
{
std::string targetId;
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- const GdriveItemDetails& itemDetails = fileState.getFileAttributes(gdriveLogin_.sharedDriveName, afsSource, false /*followLeafShortcut*/).second; //throw SysError
+ const GdriveItemDetails& itemDetails = fileState.getFileAttributes(afsSource, false /*followLeafShortcut*/).second; //throw SysError
if (itemDetails.type != GdriveItemType::shortcut)
throw SysError(L"Not a Google Drive Shortcut.");
@@ -3428,9 +3509,9 @@ private:
const Zstring shortcutName = getItemName(apTarget.afsPath);
std::string parentId;
- const GdrivePersistentSessions::AsyncAccessInfo aaiTrg = accessGlobalFileState(fsTarget.gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aaiTrg = accessGlobalFileState(fsTarget.gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- const GdriveFileState::PathStatus& ps = fileState.getPathStatus(fsTarget.gdriveLogin_.sharedDriveName, apTarget.afsPath, false /*followLeafShortcut*/); //throw SysError
+ const GdriveFileState::PathStatus& ps = fileState.getPathStatus(apTarget.afsPath, false /*followLeafShortcut*/); //throw SysError
if (ps.relPath.empty())
throw SysError(replaceCpy(_("The name %x is already used by another item."), L"%x", fmtPath(shortcutName)));
@@ -3443,7 +3524,7 @@ private:
const std::string shortcutIdNew = gdriveCreateShortcutPlain(shortcutName, parentId, targetId, aaiTrg.accessToken); //throw SysError
//buffer new file state ASAP (don't wait GDRIVE_SYNC_INTERVAL)
- accessGlobalFileState(fsTarget.gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(fsTarget.gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyShortcutCreated(aaiTrg.stateDelta, shortcutIdNew, shortcutName, parentId, targetId);
});
@@ -3465,14 +3546,14 @@ private:
L"%y", L'\n' + fmtPath(AFS::getDisplayPath(pathTo)));
};
- const GdriveFileSystem& fsTarget = static_cast<const GdriveFileSystem&>(pathTo.afsDevice.ref());
-
- if (!equalAsciiNoCase(gdriveLogin_.email, fsTarget.gdriveLogin_.email))
+ if (std::is_neq(compareDeviceSameAfsType(pathTo.afsDevice.ref())))
throw ErrorMoveUnsupported(generateErrorMsg(), _("Operation not supported between different devices."));
- //else: moving files within account works, e.g. between My Drive <-> shared drives
-
+ //note: moving files within account works, e.g. between My Drive <-> shared drives
+ // BUT: not supported by our model with separate GdriveFileStates; e.g. how to handle complexity of a moved folder (tree)?
try
{
+ const GdriveFileSystem& fsTarget = static_cast<const GdriveFileSystem&>(pathTo.afsDevice.ref());
+
//avoid duplicate Google Drive item creation by multiple threads
PathAccessLock pal(fsTarget.getGdriveRawPath(pathTo.afsPath), PathBlockType::otherWait); //throw SysError
@@ -3484,23 +3565,21 @@ private:
if (!parentPathTo ) throw SysError(L"Target is device root");
std::string itemId;
- time_t modTime = 0;
+ GdriveItemDetails itemDetails;
std::string parentIdFrom;
std::string parentIdTo;
- const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ const GdrivePersistentSessions::AsyncAccessInfo aai = accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
- GdriveItemDetails itemDetails;
- std::tie(itemId, itemDetails) = fileState.getFileAttributes(gdriveLogin_.sharedDriveName, pathFrom, false /*followLeafShortcut*/); //throw SysError
+ std::tie(itemId, itemDetails) = fileState.getFileAttributes(pathFrom, false /*followLeafShortcut*/); //throw SysError
- modTime = itemDetails.modTime;
- parentIdFrom = fileState.getItemId(gdriveLogin_.sharedDriveName, *parentPathFrom, true /*followLeafShortcut*/); //throw SysError
+ parentIdFrom = fileState.getItemId(*parentPathFrom, true /*followLeafShortcut*/); //throw SysError
- const GdriveFileState::PathStatus psTo = fileState.getPathStatus(fsTarget.gdriveLogin_.sharedDriveName, pathTo.afsPath, false /*followLeafShortcut*/); //throw SysError
+ const GdriveFileState::PathStatus psTo = fileState.getPathStatus(pathTo.afsPath, false /*followLeafShortcut*/); //throw SysError
//e.g. changing file name case only => this is not an "already exists" situation!
//also: hardlink referenced by two different paths, the source one will be unlinked
if (psTo.relPath.empty() && psTo.existingItemId == itemId)
- parentIdTo = fileState.getItemId(fsTarget.gdriveLogin_.sharedDriveName, *parentPathTo, true /*followLeafShortcut*/); //throw SysError
+ parentIdTo = fileState.getItemId(*parentPathTo, true /*followLeafShortcut*/); //throw SysError
else
{
if (psTo.relPath.empty())
@@ -3517,10 +3596,10 @@ private:
return; //nothing to do
//already existing: creates duplicate
- gdriveMoveAndRenameItem(itemId, parentIdFrom, parentIdTo, itemNameNew, modTime, aai.accessToken); //throw SysError
+ gdriveMoveAndRenameItem(itemId, parentIdFrom, parentIdTo, itemNameNew, itemDetails.modTime, aai.accessToken); //throw SysError
//buffer new file state ASAP (don't wait GDRIVE_SYNC_INTERVAL)
- accessGlobalFileState(gdriveLogin_.email, [&](GdriveFileState& fileState) //throw SysError
+ accessGlobalFileState(gdriveLogin_, [&](GdriveFileState& fileState) //throw SysError
{
fileState.notifyMoveAndRename(aai.stateDelta, itemId, parentIdFrom, parentIdTo, itemNameNew);
});
@@ -3565,7 +3644,7 @@ private:
try
{
- const std::string& accessToken = accessGlobalFileState(gdriveLogin_.email, [](GdriveFileState& fileState) {}).accessToken; //throw SysError
+ const std::string& accessToken = accessGlobalFileState(gdriveLogin_, [](GdriveFileState& fileState) {}).accessToken; //throw SysError
return gdriveGetMyDriveFreeSpace(accessToken); //throw SysError; returns < 0 if not available
}
catch (const SysError& e) { throw FileError(replaceCpy(_("Cannot determine free disk space for %x."), L"%x", fmtPath(getDisplayPath(afsPath))), e.toString()); }
@@ -3673,12 +3752,10 @@ std::vector<Zstring /*sharedDriveName*/> fff::gdriveListSharedDrives(const std::
{
try
{
- std::vector<Zstring> sharedDriveNames;
- accessGlobalFileState(accountEmail, [&](GdriveFileState& fileState) //throw SysError
- {
- sharedDriveNames = fileState.listSharedDrives();
- });
- return sharedDriveNames;
+ if (const std::shared_ptr<GdrivePersistentSessions> gps = globalGdriveSessions.get())
+ return gps->listSharedDrives(accountEmail); //throw SysError
+
+ throw SysError(formatSystemError("gdriveListSharedDrives", L"", L"Function call not allowed during init/shutdown."));
}
catch (const SysError& e) { throw FileError(replaceCpy(_("Unable to access %x."), L"%x", fmtPath(getGdriveDisplayPath({{accountEmail, Zstr("")}, AfsPath()}))), e.toString()); }
}
diff --git a/FreeFileSync/Source/afs/native.cpp b/FreeFileSync/Source/afs/native.cpp
index bf9c6ea4..e4285d66 100644
--- a/FreeFileSync/Source/afs/native.cpp
+++ b/FreeFileSync/Source/afs/native.cpp
@@ -113,7 +113,7 @@ std::vector<FsItem> getDirContentFlat(const Zstring& dirPath) //throw FileError
std::vector<FsItem> output;
for (;;)
{
- /* Linux: http://man7.org/linux/man-pages/man3/readdir_r.3.html
+ /* Linux: https://man7.org/linux/man-pages/man3/readdir_r.3.html
"It is recommended that applications use readdir(3) instead of readdir_r"
"... in modern implementations (including the glibc implementation), concurrent calls to readdir(3) that specify different directory streams are thread-safe"
@@ -312,7 +312,7 @@ void traverseFolderRecursiveNative(const std::vector<std::pair<Zstring, std::sha
class RecycleSessionNative : public AFS::RecycleSession
{
public:
- RecycleSessionNative(const Zstring& baseFolderPath) : baseFolderPath_(baseFolderPath) {}
+ explicit RecycleSessionNative(const Zstring& baseFolderPath) : baseFolderPath_(baseFolderPath) {}
void recycleItemIfExists(const AbstractPath& itemPath, const Zstring& logicalRelPath) override; //throw FileError
void tryCleanup(const std::function<void (const std::wstring& displayPath)>& notifyDeletionStatus /*throw X*/) override; //throw FileError, X
@@ -398,7 +398,7 @@ private:
class NativeFileSystem : public AbstractFileSystem
{
public:
- NativeFileSystem(const Zstring& rootPath) : rootPath_(rootPath) {}
+ explicit NativeFileSystem(const Zstring& rootPath) : rootPath_(rootPath) {}
Zstring getNativePath(const AfsPath& afsPath) const { return isNullFileSystem() ? Zstring() : nativeAppendPaths(rootPath_, afsPath.value); }
diff --git a/FreeFileSync/Source/afs/sftp.cpp b/FreeFileSync/Source/afs/sftp.cpp
index 74dc1657..92a48420 100644
--- a/FreeFileSync/Source/afs/sftp.cpp
+++ b/FreeFileSync/Source/afs/sftp.cpp
@@ -10,7 +10,6 @@
#include <zen/thread.h>
#include <zen/globals.h>
#include <zen/file_io.h>
-//#include <zen/basic_math.h>
#include <zen/socket.h>
#include <zen/open_ssl.h>
#include <zen/resolve_path.h>
@@ -18,6 +17,7 @@
#include "init_curl_libssh2.h"
#include "ftp_common.h"
#include "abstract_impl.h"
+ #include <poll.h>
using namespace zen;
using namespace fff;
@@ -178,7 +178,7 @@ std::wstring getSftpDisplayPath(const Zstring& serverName, const AfsPath& afsPat
class FatalSshError //=> consider SshSession corrupted and stop use ASAP! same conceptual level like SysError
{
public:
- FatalSshError(const std::wstring& details) : details_(details) {}
+ explicit FatalSshError(const std::wstring& details) : details_(details) {}
const std::wstring& toString() const { return details_; }
private:
@@ -186,7 +186,7 @@ private:
};
-constinit2 Global<UniSessionCounter> globalSftpSessionCount;
+constinit Global<UniSessionCounter> globalSftpSessionCount;
GLOBAL_RUN_ONCE(globalSftpSessionCount.set(createUniSessionCounter()));
@@ -514,13 +514,7 @@ public:
static void waitForTraffic(const std::vector<SshSession*>& sshSessions, int timeoutSec) //throw FatalSshError
{
//reference: session.c: _libssh2_wait_socket()
-
- SocketType nfds = 0;
- fd_set readfds = {}; //covers FD_ZERO
- fd_set writefds = {}; //
- int readCount = 0; //sigh: using fd_set::fd_count is not portable
- int writeCount = 0; //
-
+ std::vector<pollfd> fds;
std::chrono::steady_clock::time_point startTimeMin = std::chrono::steady_clock::time_point::max();
for (SshSession* session : sshSessions)
@@ -528,57 +522,44 @@ public:
assert(::libssh2_session_last_errno(session->sshSession_) == LIBSSH2_ERROR_EAGAIN);
assert(session->nbInfo_.commandPending || std::any_of(session->sftpChannels_.begin(), session->sftpChannels_.end(), [](SftpChannelInfo& ci) { return ci.nbInfo.commandPending; }));
+ pollfd pfd = {session->socket_->get()};
+
const int dir = ::libssh2_session_block_directions(session->sshSession_);
assert(dir != 0); //we assert a blocked direction after libssh2 returned LIBSSH2_ERROR_EAGAIN!
if (dir & LIBSSH2_SESSION_BLOCK_INBOUND)
- {
- if (readCount++ >= FD_SETSIZE)
- throw FatalSshError(formatSystemError("FD_SET(readfds)", L"", _P("Cannot wait on more than 1 connection at a time.",
- "Cannot wait on more than %x connections at a time.", FD_SETSIZE)));
- FD_SET(session->socket_->get(), &readfds);
- }
+ pfd.events |= POLLIN;
if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
- {
- if (writeCount++ >= FD_SETSIZE)
- throw FatalSshError(formatSystemError("FD_SET(writefds)", L"", _P("Cannot wait on more than 1 connection at a time.",
- "Cannot wait on more than %x connections at a time.", FD_SETSIZE)));
- FD_SET(session->socket_->get(), &writefds);
- }
+ pfd.events |= POLLOUT;
- nfds = std::max(nfds, session->socket_->get());
+ if (pfd.events != 0)
+ fds.push_back(pfd);
- for (SftpChannelInfo& ci : session->sftpChannels_)
+ for (const SftpChannelInfo& ci : session->sftpChannels_)
if (ci.nbInfo.commandPending)
startTimeMin = std::min(startTimeMin, ci.nbInfo.commandStartTime);
if (session->nbInfo_.commandPending)
startTimeMin = std::min(startTimeMin, session->nbInfo_.commandStartTime);
}
- if (readCount > 0 || writeCount > 0)
+ if (!fds.empty())
{
assert(startTimeMin != std::chrono::steady_clock::time_point::max());
const auto now = std::chrono::steady_clock::now();
const auto endTime = startTimeMin + std::chrono::seconds(timeoutSec);
- if (now > endTime)
+ if (now >= endTime)
return; //time-out! => let next tryNonBlocking() call fail with detailed error!
const auto waitTimeMs = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - now).count();
- timeval tv = {};
- tv.tv_sec = static_cast<long>(waitTimeMs / 1000);
- tv.tv_usec = static_cast<long>(waitTimeMs - tv.tv_sec * 1000) * 1000;
-
- //WSAPoll is broken, ::poll() on macOS even worse: https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
- //perf: no significant difference compared to ::WSAPoll()
- const int rc = ::select(nfds + 1, //int nfds
- readCount > 0 ? &readfds : nullptr, //fd_set* readfds
- writeCount > 0 ? &writefds : nullptr, //fd_set* writefds
- nullptr, //fd_set* exceptfds
- &tv); //struct timeval* timeout
- if (rc == 0)
- return; //time-out! => let next tryNonBlocking() call fail with detailed error!
- if (rc < 0)
- //consider SSH sessions corrupted! => isHealthy() will see pending commands
- throw FatalSshError(formatSystemError("select", getLastError()));
+ //is poll() on macOS broken? https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/
+ // it seems Daniel only takes issue with "empty" input handling!? => not an issue for us
+ const char* functionName = "poll";
+ const int rv = ::poll(&fds[0], //struct pollfd* fds
+ fds.size(), //nfds_t nfds
+ waitTimeMs); //int timeout [ms]
+ if (rv == 0) //time-out! => let next tryNonBlocking() call fail with detailed error!
+ return;
+ if (rv < 0) //consider SSH sessions corrupted! => isHealthy() will see pending commands
+ throw FatalSshError(formatSystemError(functionName, getLastError()));
}
else assert(false);
}
@@ -968,7 +949,7 @@ private:
//--------------------------------------------------------------------------------------
UniInitializer globalStartupInitSftp(*globalSftpSessionCount.get());
-constinit2 Global<SftpSessionManager> globalSftpSessionManager; //caveat: life time must be subset of static UniInitializer!
+constinit Global<SftpSessionManager> globalSftpSessionManager; //caveat: life time must be subset of static UniInitializer!
//--------------------------------------------------------------------------------------
@@ -1515,7 +1496,7 @@ private:
class SftpFileSystem : public AbstractFileSystem
{
public:
- SftpFileSystem(const SftpLogin& login) : login_(login) {}
+ explicit SftpFileSystem(const SftpLogin& login) : login_(login) {}
const SftpLogin& getLogin() const { return login_; }
@@ -1774,7 +1755,7 @@ private:
[&](const SshSession::Details& sd) //noexcept!
{
/* LIBSSH2_SFTP_RENAME_NATIVE: "The server is free to do the rename operation in whatever way it chooses. Any other set flags are to be taken as hints to the server." No, thanks!
- LIBSSH2_SFTP_RENAME_OVERWRITE: "No overwriting rename in [SFTP] v3/v4" http://www.greenend.org.uk/rjk/sftp/sftpversions.html
+ LIBSSH2_SFTP_RENAME_OVERWRITE: "No overwriting rename in [SFTP] v3/v4" https://www.greenend.org.uk/rjk/sftp/sftpversions.html
Test: LIBSSH2_SFTP_RENAME_OVERWRITE is not honored on freefilesync.org, no matter if LIBSSH2_SFTP_RENAME_NATIVE is set or not
=> makes sense since SFTP v3 does not honor the additional flags that libssh2 sends!
diff --git a/FreeFileSync/Source/base/algorithm.cpp b/FreeFileSync/Source/base/algorithm.cpp
index 37b1c21a..0a2cf79f 100644
--- a/FreeFileSync/Source/base/algorithm.cpp
+++ b/FreeFileSync/Source/base/algorithm.cpp
@@ -1686,6 +1686,30 @@ TempFileBuffer::~TempFileBuffer()
}
+void TempFileBuffer::createTempFolderPath() //throw FileError
+{
+ if (tempFolderPath_.empty())
+ {
+ //generate random temp folder path e.g. C:\Users\Zenju\AppData\Local\Temp\FFS-068b2e88
+ const uint32_t shortGuid = getCrc32(generateGUID()); //no need for full-blown (pseudo-)random numbers for this one-time invocation
+
+ const Zstring& tempPathTmp = appendSeparator(getTempFolderPath()) + //throw FileError
+ Zstr("FFS-") + printNumber<Zstring>(Zstr("%08x"), static_cast<unsigned int>(shortGuid));
+
+ createDirectoryIfMissingRecursion(tempPathTmp); //throw FileError
+
+ tempFolderPath_ = tempPathTmp;
+ }
+}
+
+
+ Zstring TempFileBuffer::getAndCreateFolderPath() //throw FileError
+ {
+ createTempFolderPath(); //throw FileError
+ return tempFolderPath_;
+ }
+
+
//returns empty if not available (item not existing, error during copy)
Zstring TempFileBuffer::getTempPath(const FileDescriptor& descr) const
{
@@ -1705,25 +1729,13 @@ void TempFileBuffer::createTempFiles(const std::set<FileDescriptor>& workLoad, P
bytesTotal += descr.attr.fileSize;
callback.initNewPhase(itemTotal, bytesTotal, ProcessPhase::none); //throw X
-
//------------------------------------------------------------------------------
- if (tempFolderPath_.empty())
- {
const std::wstring errMsg = tryReportingError([&]
{
- //generate random temp folder path e.g. C:\Users\Zenju\AppData\Local\Temp\FFS-068b2e88
- const uint32_t shortGuid = getCrc32(generateGUID()); //no need for full-blown (pseudo-)random numbers for this one-time invocation
-
- const Zstring& tempPathTmp = appendSeparator(getTempFolderPath()) + //throw FileError
- Zstr("FFS-") + printNumber<Zstring>(Zstr("%08x"), static_cast<unsigned int>(shortGuid));
-
- createDirectoryIfMissingRecursion(tempPathTmp); //throw FileError
-
- tempFolderPath_ = tempPathTmp;
+ createTempFolderPath(); //throw FileError
}, callback); //throw X
if (!errMsg.empty()) return;
- }
for (const FileDescriptor& descr : workLoad)
{
diff --git a/FreeFileSync/Source/base/algorithm.h b/FreeFileSync/Source/base/algorithm.h
index 7b2f8a84..75b7e7a6 100644
--- a/FreeFileSync/Source/base/algorithm.h
+++ b/FreeFileSync/Source/base/algorithm.h
@@ -90,15 +90,20 @@ public:
TempFileBuffer() {}
~TempFileBuffer();
+ Zstring getAndCreateFolderPath(); //throw FileError
+
Zstring getTempPath(const FileDescriptor& descr) const; //returns empty if not in buffer (item not existing, error during copy)
//contract: only add files not yet in the buffer!
void createTempFiles(const std::set<FileDescriptor>& workLoad, ProcessCallback& callback);
+
private:
TempFileBuffer (const TempFileBuffer&) = delete;
TempFileBuffer& operator=(const TempFileBuffer&) = delete;
+void createTempFolderPath(); //throw FileError
+
std::map<FileDescriptor, Zstring> tempFilePaths_;
Zstring tempFolderPath_;
};
diff --git a/FreeFileSync/Source/config.cpp b/FreeFileSync/Source/config.cpp
index 3b9311a6..c9383329 100644
--- a/FreeFileSync/Source/config.cpp
+++ b/FreeFileSync/Source/config.cpp
@@ -2426,6 +2426,8 @@ void writeConfig(const XmlGlobalSettings& cfg, XmlOut& out)
out["FolderHistory" ].attribute("MaxSize", cfg.folderHistoryMax);
+ warn_static("csvFileLastSelected is obsolete: get rid?")
+
out["CsvExport" ].attribute("LastSelected", cfg.csvFileLastSelected);
out["SftpKeyFile"].attribute("LastSelected", cfg.sftpKeyFileLastSelected);
diff --git a/FreeFileSync/Source/localization.cpp b/FreeFileSync/Source/localization.cpp
index dacd5711..e2406bdf 100644
--- a/FreeFileSync/Source/localization.cpp
+++ b/FreeFileSync/Source/localization.cpp
@@ -442,8 +442,10 @@ public:
//const char* currentLocale = std::setlocale(LC_ALL, nullptr);
//call std::setlocale()?
- //wxWidgets overwrites the default locale "C" with a locale matching sysLng_, e.g. "en_US.UTF-8"
- //which may be *different* from actual user-preferred locale as set up in "Region & Language/Formats"! => fix:
+ //Linux: wxWidgets overwrites the default locale "C" with a locale matching sysLng_, e.g. "en_US.UTF-8"
+ // which may be *different* from actual user-preferred locale as set up in "Region & Language/Formats"! => fix:
+
+ //Windows: apparently needed: https://freefilesync.org/forum/viewtopic.php?t=8455
[[maybe_unused]] const char* newLocale = std::setlocale(LC_ALL, "" /*== user-preferred locale*/);
assert(newLocale);
diff --git a/FreeFileSync/Source/parse_plural.h b/FreeFileSync/Source/parse_plural.h
index 67f70b27..2484b265 100644
--- a/FreeFileSync/Source/parse_plural.h
+++ b/FreeFileSync/Source/parse_plural.h
@@ -67,7 +67,7 @@ private:
//--------------------------- implementation ---------------------------
//https://www.gnu.org/software/hello/manual/gettext/Plural-forms.html
-//http://translate.sourceforge.net/wiki/l10n/pluralforms
+//https://translate.sourceforge.net/wiki/l10n/pluralforms
/*
Grammar for Plural forms parser
-------------------------------
diff --git a/FreeFileSync/Source/ui/cfg_grid.cpp b/FreeFileSync/Source/ui/cfg_grid.cpp
index 98a8d50b..2f1f1776 100644
--- a/FreeFileSync/Source/ui/cfg_grid.cpp
+++ b/FreeFileSync/Source/ui/cfg_grid.cpp
@@ -6,7 +6,6 @@
#include "cfg_grid.h"
#include <zen/time.h>
-//#include <zen/basic_math.h>
#include <zen/process_exec.h>
#include <wx+/dc.h>
#include <wx+/rtl.h>
diff --git a/FreeFileSync/Source/ui/main_dlg.cpp b/FreeFileSync/Source/ui/main_dlg.cpp
index 837250ab..a5d8d1c1 100644
--- a/FreeFileSync/Source/ui/main_dlg.cpp
+++ b/FreeFileSync/Source/ui/main_dlg.cpp
@@ -1971,7 +1971,7 @@ void MainDialog::onGridKeyEvent(wxKeyEvent& event, Grid& grid, bool leftSide)
{
case 'C':
case WXK_INSERT: //CTRL + C || CTRL + INS
- copySelectionToClipboard({ m_gridMainL, m_gridMainR} );
+ copySelectionToClipboard({m_gridMainL, m_gridMainR});
return; // -> swallow event! don't allow default grid commands!
case 'T': //CTRL + T
@@ -2882,15 +2882,20 @@ void MainDialog::cfgHistoryRemoveObsolete(const std::vector<Zstring>& filePaths)
}
-void MainDialog::updateUnsavedCfgStatus()
+std::vector<std::wstring> MainDialog::getJobNames() const
{
- const Zstring activeCfgFilePath = activeConfigFiles_.size() == 1 && !equalNativePath(activeConfigFiles_[0], lastRunConfigPath_) ? activeConfigFiles_[0] : Zstring();
-
std::vector<std::wstring> jobNames;
for (const Zstring& cfgFilePath : activeConfigFiles_)
jobNames.push_back(equalNativePath(cfgFilePath, lastRunConfigPath_) ?
L'[' + _("Last session") + L']' :
extractJobName(cfgFilePath));
+ return jobNames;
+}
+
+
+void MainDialog::updateUnsavedCfgStatus()
+{
+ const Zstring activeCfgFilePath = activeConfigFiles_.size() == 1 && !equalNativePath(activeConfigFiles_[0], lastRunConfigPath_) ? activeConfigFiles_[0] : Zstring();
const bool haveUnsavedCfg = lastSavedCfg_ != getConfig();
@@ -2918,9 +2923,10 @@ void MainDialog::updateUnsavedCfgStatus()
title += utfTo<wxString>(activeCfgFilePath);
else if (activeConfigFiles_.size() > 1)
{
- title += jobNames[0];
- std::for_each(jobNames.begin() + 1, jobNames.end(), [&](const std::wstring& jobName)
- { title += L" + " + jobName; });
+ for (const std::wstring& jobName : getJobNames())
+ title += jobName + L" + ";
+ if (endsWith(title, L" + "))
+ title.resize(title.size() - 3);
}
else
{
@@ -4117,7 +4123,7 @@ void MainDialog::updateGui()
updateTopButton(*m_buttonSync, loadImage("start_sync"), getVariantName(syncVar), syncVarIconName, folderCmp_.empty());
m_panelTopButtons->Layout();
- m_menuItemExportList->Enable(!folderCmp_.empty()); //a CSV without even folder names confuses users: https://freefilesync.org/forum/viewtopic.php?t=4787
+ m_menuItemExportList->Enable(!folderCmp_.empty()); //empty CSV confuses users: https://freefilesync.org/forum/viewtopic.php?t=4787
//auiMgr_.Update(); -> doesn't seem to be needed
}
@@ -4231,12 +4237,6 @@ void MainDialog::onStartSync(wxCommandEvent& event)
const std::chrono::system_clock::time_point syncStartTime = std::chrono::system_clock::now();
- std::vector<std::wstring> jobNames;
- for (const Zstring& cfgFilePath : activeConfigFiles_)
- jobNames.push_back(equalNativePath(cfgFilePath, lastRunConfigPath_) ?
- L'[' + _("Last session") + L']' :
- extractJobName(cfgFilePath));
-
using FinalRequest = StatusHandlerFloatingDialog::FinalRequest;
FinalRequest finalRequest = FinalRequest::none;
{
@@ -4245,7 +4245,7 @@ void MainDialog::onStartSync(wxCommandEvent& event)
//run this->enableGuiElements() BEFORE "finalRequest" buf AFTER StatusHandlerFloatingDialog::reportResults()
//class handling status updates and error messages
- StatusHandlerFloatingDialog statusHandler(this, jobNames, syncStartTime,
+ StatusHandlerFloatingDialog statusHandler(this, getJobNames(), syncStartTime,
guiCfg.mainCfg.ignoreErrors,
guiCfg.mainCfg.autoRetryCount,
guiCfg.mainCfg.autoRetryDelay,
@@ -5470,20 +5470,6 @@ void MainDialog::onMenuOptions(wxCommandEvent& event)
void MainDialog::onMenuExportFileList(wxCommandEvent& event)
{
- std::optional<Zstring> defaultFolderPath = getParentFolderPath(globalCfg_.csvFileLastSelected);
-
- const Zstring defaultFileName = !globalCfg_.csvFileLastSelected.empty() ?
- afterLast(globalCfg_.csvFileLastSelected, FILE_NAME_SEPARATOR, IfNotFoundReturn::all) :
- Zstr("FileList.csv");
-
- wxFileDialog fileSelector(this, wxString() /*message*/, utfTo<wxString>(defaultFolderPath ? *defaultFolderPath : Zstr("")), utfTo<wxString>(defaultFileName),
- _("Comma-separated values") + L" (*.csv)|*.csv" + L"|" +_("All files") + L" (*.*)|*",
- wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
- if (fileSelector.ShowModal() != wxID_OK)
- return;
- const Zstring csvFilePath = globalCfg_.csvFileLastSelected = utfTo<Zstring>(fileSelector.GetPath());
- //---------------------------------------------------------------------
-
wxBusyCursor dummy;
//https://en.wikipedia.org/wiki/Comma-separated_values
@@ -5502,10 +5488,10 @@ void MainDialog::onMenuExportFileList(wxCommandEvent& event)
return std::move(tmp);
};
+ //generate header
std::string header; //perf: wxString doesn't model exponential growth and so is out, std::string doesn't give performance guarantee!
header += BYTE_ORDER_MARK_UTF8;
- //base folders
header += fmtValue(_("Folder Pairs")) + LINE_BREAK;
std::for_each(begin(folderCmp_), end(folderCmp_), [&](BaseFolderPair& baseFolder)
{
@@ -5514,7 +5500,6 @@ void MainDialog::onMenuExportFileList(wxCommandEvent& event)
});
header += LINE_BREAK;
- //write header
auto provLeft = m_gridMainL->getDataProvider();
auto provCenter = m_gridMainC->getDataProvider();
auto provRight = m_gridMainR->getDataProvider();
@@ -5553,15 +5538,27 @@ void MainDialog::onMenuExportFileList(wxCommandEvent& event)
try
{
+ Zstring title = Zstr("FreeFileSync");
+ if (const std::vector<std::wstring>& jobNames = getJobNames();
+ !jobNames.empty())
+ {
+ title = utfTo<Zstring>(jobNames[0]);
+ std::for_each(jobNames.begin() + 1, jobNames.end(), [&](const std::wstring& jobName)
+ { title += Zstr(" + ") + utfTo<Zstring>(jobName); });
+ }
+
+ const Zstring shortGuid = printNumber<Zstring>(Zstr("%04x"), static_cast<unsigned int>(getCrc16(generateGUID())));
+ const Zstring csvFilePath = appendSeparator(tempFileBuf_.getAndCreateFolderPath()) + //throw FileError
+ title + Zstr("~") + shortGuid + Zstr(".csv");
+
+
TempFileOutput fileOut(csvFilePath, nullptr /*notifyUnbufferedIO*/); //throw FileError
fileOut.write(&header[0], header.size()); //throw FileError, (X)
- //main grid: write rows one after the other instead of creating one big string: memory allocation might fail; think 1 million rows!
- /*
- performance test case "export 600.000 rows" to CSV:
- aproach 1. assemble single temporary string, then write file: 4.6s
- aproach 2. write to buffered file output directly for each row: 6.4s
- */
+ /* main grid: write rows one after the other instead of creating one big string: memory allocation might fail; think 1 million rows!
+ performance test case "export 600.000 rows" to CSV:
+ aproach 1. assemble single temporary string, then write file: 4.6s
+ aproach 2. write to buffered file output directly for each row: 6.4s */
std::string buffer;
const size_t rowCount = m_gridMainL->getRowCount();
for (size_t row = 0; row < rowCount; ++row)
@@ -5590,6 +5587,8 @@ void MainDialog::onMenuExportFileList(wxCommandEvent& event)
}
fileOut.commit(); //throw FileError, (X)
+ openWithDefaultApp(csvFilePath); //throw FileError
+
flashStatusInformation(_("File list exported"));
}
catch (const FileError& e)
diff --git a/FreeFileSync/Source/ui/main_dlg.h b/FreeFileSync/Source/ui/main_dlg.h
index dc0ea8d1..2064d156 100644
--- a/FreeFileSync/Source/ui/main_dlg.h
+++ b/FreeFileSync/Source/ui/main_dlg.h
@@ -104,6 +104,8 @@ private:
void updateStatistics(); // more fine-grained updaters
void updateUnsavedCfgStatus(); //
+ std::vector<std::wstring> getJobNames() const;
+
//context menu functions
std::vector<FileSystemObject*> getGridSelection(bool fromLeft = true, bool fromRight = true) const;
std::vector<FileSystemObject*> getTreeSelection() const;
diff --git a/FreeFileSync/Source/ui/small_dlgs.cpp b/FreeFileSync/Source/ui/small_dlgs.cpp
index b691547a..f1d7c501 100644
--- a/FreeFileSync/Source/ui/small_dlgs.cpp
+++ b/FreeFileSync/Source/ui/small_dlgs.cpp
@@ -815,7 +815,7 @@ CopyToDialog::CopyToDialog(wxWindow* parent,
it re-enables all windows that are supposed to be disabled during the current modal loop!
This only affects Ubuntu/wxGTK! No such issue on Debian/wxGTK or Suse/wxGTK
=> another Unity problem like the following?
- http://trac.wxwidgets.org/ticket/14823 "Menu not disabled when showing modal dialogs in wxGTK under Unity" */
+ https://trac.wxwidgets.org/ticket/14823 "Menu not disabled when showing modal dialogs in wxGTK under Unity" */
const auto& [itemList, itemCount] = getSelectedItemsAsString(rowsOnLeft, rowsOnRight);
@@ -941,7 +941,7 @@ DeleteDialog::DeleteDialog(wxWindow* parent,
it re-enables all windows that are supposed to be disabled during the current modal loop!
This only affects Ubuntu/wxGTK! No such issue on Debian/wxGTK or Suse/wxGTK
=> another Unity problem like the following?
- http://trac.wxwidgets.org/ticket/14823 "Menu not disabled when showing modal dialogs in wxGTK under Unity" */
+ https://trac.wxwidgets.org/ticket/14823 "Menu not disabled when showing modal dialogs in wxGTK under Unity" */
m_checkBoxUseRecycler->SetValue(useRecycleBin);
diff --git a/FreeFileSync/Source/version/version.h b/FreeFileSync/Source/version/version.h
index dad288ec..b34f3ea4 100644
--- a/FreeFileSync/Source/version/version.h
+++ b/FreeFileSync/Source/version/version.h
@@ -3,7 +3,7 @@
namespace fff
{
-const char ffsVersion[] = "11.10"; //internal linkage!
+const char ffsVersion[] = "11.11"; //internal linkage!
const char FFS_VERSION_SEPARATOR = '.';
}
diff --git a/libcurl/curl_wrap.h b/libcurl/curl_wrap.h
index 2c445771..2ab52d47 100644
--- a/libcurl/curl_wrap.h
+++ b/libcurl/curl_wrap.h
@@ -136,11 +136,12 @@ std::wstring formatCurlStatusCode(CURLcode sc)
ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_RECURSIVE_API_CALL);
ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_AUTH_ERROR);
ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_HTTP3);
- ZEN_CHECK_CASE_FOR_CONSTANT(CURL_LAST);
ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_QUIC_CONNECT_ERROR);
ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_PROXY);
+ ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SSL_CLIENTCERT);
+ ZEN_CHECK_CASE_FOR_CONSTANT(CURL_LAST);
}
- static_assert(CURL_LAST == CURLE_PROXY + 1);
+ static_assert(CURL_LAST == CURLE_SSL_CLIENTCERT + 1);
return replaceCpy<std::wstring>(L"Curl status %x", L"%x", numberTo<std::wstring>(static_cast<int>(sc)));
}
diff --git a/wx+/file_drop.h b/wx+/file_drop.h
index e5de8f95..68024091 100644
--- a/wx+/file_drop.h
+++ b/wx+/file_drop.h
@@ -18,7 +18,7 @@ namespace zen
{
/* register simple file drop event (without issue of freezing dialogs and without wxFileDropTarget overdesign)
CAVEAT: a drop target window must not be directly or indirectly contained within a wxStaticBoxSizer until the following wxGTK bug
- is fixed. According to wxWidgets release cycles this is expected to be: never http://trac.wxwidgets.org/ticket/2763
+ is fixed. According to wxWidgets release cycles this is expected to be: never https://trac.wxwidgets.org/ticket/2763
1. setup a window to emit EVENT_DROP_FILE:
- simple file system paths: setupFileDrop
diff --git a/zen/file_access.cpp b/zen/file_access.cpp
index fb770f19..db4f2505 100644
--- a/zen/file_access.cpp
+++ b/zen/file_access.cpp
@@ -668,7 +668,7 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target
/* we cannot set the target file times (::futimes) while the file descriptor is still open after a write operation:
this triggers bugs on Samba shares where the modification time is set to current time instead.
Linux: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=340236
- http://comments.gmane.org/gmane.linux.file-systems.cifs/2854
+ http://comments.gmane.org/gmane.linux.file-systems.cifs/2854
macOS: https://freefilesync.org/forum/viewtopic.php?t=356 */
setWriteTimeNative(targetFile, sourceInfo.st_mtim, ProcSymlink::follow); //throw FileError
}
diff --git a/zen/i18n.h b/zen/i18n.h
index 160b9625..31bb3df8 100644
--- a/zen/i18n.h
+++ b/zen/i18n.h
@@ -58,7 +58,7 @@ std::shared_ptr<const TranslationHandler> getTranslator();
namespace impl
{
//getTranslator() may be called even after static objects of this translation unit are destroyed!
-inline constinit2 Global<const TranslationHandler> globalTranslationHandler;
+inline constinit Global<const TranslationHandler> globalTranslationHandler;
}
inline
diff --git a/zen/legacy_compiler.h b/zen/legacy_compiler.h
index 66b750c9..50d340ca 100644
--- a/zen/legacy_compiler.h
+++ b/zen/legacy_compiler.h
@@ -24,15 +24,9 @@
namespace std
{
-
-
}
//---------------------------------------------------------------------------------
-//constinit
- #define constinit2 constinit //GCC, clang have it
-
-
namespace zen
{
double fromChars(const char* first, const char* last);
diff --git a/zen/string_base.h b/zen/string_base.h
index f0899433..5c17fb47 100644
--- a/zen/string_base.h
+++ b/zen/string_base.h
@@ -10,7 +10,7 @@
#include <algorithm>
#include <atomic>
#include "string_tools.h"
-#include "legacy_compiler.h" //constinit2
+#include "legacy_compiler.h" //constinit
//Zbase - a policy based string class optimizing performance and flexibility
@@ -209,7 +209,7 @@ private:
static_assert(offsetof(GlobalEmptyString, nullTerm) - offsetof(GlobalEmptyString, descr) == sizeof(Descriptor), "no gap!");
static_assert(std::is_trivially_destructible_v<GlobalEmptyString>, "this memory needs to live forever");
- inline static constinit2 GlobalEmptyString globalEmptyString; //constinit: dodge static initialization order fiasco!
+ inline static constinit GlobalEmptyString globalEmptyString; //constinit: dodge static initialization order fiasco!
};
diff --git a/zen/string_tools.h b/zen/string_tools.h
index 8150df05..5f9273c9 100644
--- a/zen/string_tools.h
+++ b/zen/string_tools.h
@@ -568,9 +568,8 @@ template <class S, class T, class Num> inline
S printNumber(const T& format, const Num& number) //format a single number using ::sprintf
{
#ifdef __cpp_lib_format
-#error refactor
+#error refactor?
#endif
-
static_assert(std::is_same_v<GetCharTypeT<S>, GetCharTypeT<T>>);
const int BUFFER_SIZE = 128;
diff --git a/zen/time.h b/zen/time.h
index b3b903b6..9b5f670e 100644
--- a/zen/time.h
+++ b/zen/time.h
@@ -159,11 +159,23 @@ TimeComp getUtcTime2(time_t utc)
{
//1. convert: seconds since year 1:
//...
+ //assert(time_t is signed)
//TODO: what if < 0?
long long remDays = utc / (24 * 3600);
long long remSecs = utc % (24 * 3600);
+ //days per year
+ const int dpYearStd = 365;
+ const int dpYearLeap = dpYearStd + 1;
+ const int dp4Years = 3 * dpYearStd + dpYearLeap;
+ const int dp100YearsStd = 25 * dp4Years - 1; //no leap days for centuries...
+ const int dp100YearsExc = 25 * dp4Years; //...except if divisible by 400
+ const int dp400Years = 3 * dp100YearsStd + dp100YearsExc;
+
+
+
+
const int daysPer4Years = 4 * 365 /*usual days per year*/ + 1 /*including leap day*/;
const int daysPerYear = 365; //non-leap
const int daysPer100Years = 25 * daysPer4Years - 1;
@@ -197,6 +209,8 @@ TimeComp getUtcTime2(time_t utc)
+ const char daysPerMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
//first four years of century:
bgstack15