Browse Source

File owner and group, if available, are recorded in <stat> tag of XML log and consequently .NET assembly Session.GetFileInfo method is able to retrieve them.

Source commit: 20837866126127e74f3473183d591a6f372a810d
Martin Prikryl 8 years ago
parent
commit
6934949493
1 changed files with 35 additions and 40 deletions
  1. 35 40
      source/core/SessionInfo.cpp

+ 35 - 40
source/core/SessionInfo.cpp

@@ -148,51 +148,13 @@ public:
           for (int Index = 0; Index < FFileList->Count; Index++)
           {
             TRemoteFile * File = FFileList->Files[Index];
-
-            FLog->AddIndented(L"    <file>");
-            FLog->AddIndented(FORMAT(L"      <filename value=\"%s\" />", (XmlAttributeEscape(File->FileName))));
-            FLog->AddIndented(FORMAT(L"      <type value=\"%s\" />", (XmlAttributeEscape(File->Type))));
-            if (!File->IsDirectory)
-            {
-              FLog->AddIndented(FORMAT(L"      <size value=\"%s\" />", (IntToStr(File->Size))));
-            }
-            if (File->ModificationFmt != mfNone)
-            {
-              FLog->AddIndented(FORMAT(L"      <modification value=\"%s\" />", (StandardTimestamp(File->Modification))));
-            }
-            if (!File->Rights->Unknown)
-            {
-              FLog->AddIndented(FORMAT(L"      <permissions value=\"%s\" />", (XmlAttributeEscape(File->Rights->Text))));
-            }
-            if (File->Owner.IsSet)
-            {
-              FLog->AddIndented(FORMAT(L"      <owner value=\"%s\" />", (XmlAttributeEscape(File->Owner.DisplayText))));
-            }
-            if (File->Group.IsSet)
-            {
-              FLog->AddIndented(FORMAT(L"      <group value=\"%s\" />", (XmlAttributeEscape(File->Group.DisplayText))));
-            }
-            FLog->AddIndented(L"    </file>");
+            RecordFile(L"    ", File, true);
           }
           FLog->AddIndented(L"  </files>");
         }
         if (FFile != NULL)
         {
-          FLog->AddIndented(L"  <file>");
-          FLog->AddIndented(FORMAT(L"    <type value=\"%s\" />", (XmlAttributeEscape(FFile->Type))));
-          if (!FFile->IsDirectory)
-          {
-            FLog->AddIndented(FORMAT(L"    <size value=\"%s\" />", (IntToStr(FFile->Size))));
-          }
-          if (FFile->ModificationFmt != mfNone)
-          {
-            FLog->AddIndented(FORMAT(L"    <modification value=\"%s\" />", (StandardTimestamp(FFile->Modification))));
-          }
-          if (!FFile->Rights->Unknown)
-          {
-            FLog->AddIndented(FORMAT(L"    <permissions value=\"%s\" />", (XmlAttributeEscape(FFile->Rights->Text))));
-          }
-          FLog->AddIndented(L"  </file>");
+          RecordFile(L"  ", FFile, false);
         }
         if (FState == RolledBack)
         {
@@ -349,6 +311,34 @@ protected:
     FValues->Add(Value);
   }
 
+  void __fastcall RecordFile(const UnicodeString & Indent, TRemoteFile * File, bool IncludeFileName)
+  {
+    FLog->AddIndented(Indent + L"<file>");
+    FLog->AddIndented(Indent + FORMAT(L"  <filename value=\"%s\" />", (XmlAttributeEscape(File->FileName))));
+    FLog->AddIndented(Indent + FORMAT(L"  <type value=\"%s\" />", (XmlAttributeEscape(File->Type))));
+    if (!File->IsDirectory)
+    {
+      FLog->AddIndented(Indent + FORMAT(L"  <size value=\"%s\" />", (IntToStr(File->Size))));
+    }
+    if (File->ModificationFmt != mfNone)
+    {
+      FLog->AddIndented(Indent + FORMAT(L"  <modification value=\"%s\" />", (StandardTimestamp(File->Modification))));
+    }
+    if (!File->Rights->Unknown)
+    {
+      FLog->AddIndented(Indent + FORMAT(L"  <permissions value=\"%s\" />", (XmlAttributeEscape(File->Rights->Text))));
+    }
+    if (File->Owner.IsSet)
+    {
+      FLog->AddIndented(Indent + FORMAT(L"  <owner value=\"%s\" />", (XmlAttributeEscape(File->Owner.DisplayText))));
+    }
+    if (File->Group.IsSet)
+    {
+      FLog->AddIndented(Indent + FORMAT(L"  <group value=\"%s\" />", (XmlAttributeEscape(File->Group.DisplayText))));
+    }
+    FLog->AddIndented(Indent + L"</file>");
+  }
+
 private:
   TActionLog * FLog;
   TLogAction FAction;
@@ -1228,6 +1218,11 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data)
       ADF(L"HTTPS: %s [Client certificate: %s]",
         (BooleanToEngStr(FtpsOn), LogSensitive(Data->TlsCertificateFile)));
     }
+    if (Data->FSProtocol == fsS3)
+    {
+      FtpsOn = (Data->Ftps != ftpsNone);
+      ADF(L"HTTPS: %s", (BooleanToEngStr(FtpsOn)));
+    }
     if (FtpsOn)
     {
       if (Data->FSProtocol == fsFTP)