Skip to content

Commit

Permalink
Merge branch 'develop2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yar229 committed Jan 31, 2018
2 parents 8474fe0 + e4b356a commit 84c49dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
31 changes: 21 additions & 10 deletions MailRuCloud/MailRuCloudApi/Extensions/DtoImportWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace YaR.MailRuCloud.Api.Extensions
{
internal static class DtoImportWeb
{
private static readonly log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(DtoImportWeb));

public static UnpublishResult ToUnpublishResult(this UnpublishRequest.Result data)
{
var res = new UnpublishResult
Expand Down Expand Up @@ -268,14 +270,15 @@ private static File ToFile(this FolderInfoResult.FolderInfoBody.FolderInfoProps
? item.home
: WebDavPath.Combine(WebDavPath.Parent(item.home), nameReplacement);


var file = new File(path ?? item.name, item.size, item.hash)
{
PublicLink =
string.IsNullOrEmpty(item.weblink) ? string.Empty : item.weblink,
CreationTimeUtc = UnixTimeStampToDateTime(item.mtime),
LastAccessTimeUtc = UnixTimeStampToDateTime(item.mtime),
LastWriteTimeUtc = UnixTimeStampToDateTime(item.mtime),
PublicLink = string.IsNullOrEmpty(item.weblink) ? string.Empty : item.weblink
};
var dt = UnixTimeStampToDateTime(item.mtime, file.CreationTimeUtc);
file.CreationTimeUtc =
file.LastAccessTimeUtc =
file.LastWriteTimeUtc = dt;

return file;
}
Expand Down Expand Up @@ -304,12 +307,20 @@ private static IEnumerable<File> ToGroupedFiles(this IEnumerable<File> list)
return groupedFiles;
}

private static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
private static DateTime UnixTimeStampToDateTime(double unixTimeStamp, DateTime defaultvalue)
{
// Unix timestamp is seconds past epoch
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp); //.ToLocalTime(); - doesn't need, clients usially convert to localtime by itself
return dtDateTime;
try
{
// Unix timestamp is seconds past epoch
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp); //.ToLocalTime(); - doesn't need, clients usially convert to localtime by itself
return dtDateTime;
}
catch (Exception e)
{
Logger.Error($"Error converting unixTimeStamp {unixTimeStamp} to DateTime, {e.Message}");
return defaultvalue;
}
}
}
}
4 changes: 2 additions & 2 deletions MailRuCloud/MailRuCloudApi/MailRuCloudApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<RootNamespace>YaR.MailRuCloud.Api</RootNamespace>
<AssemblyName>MailRuCloud.Api</AssemblyName>
<AssemblyVersion>1.10.1.9</AssemblyVersion>
<FileVersion>1.10.1.9</FileVersion>
<AssemblyVersion>1.10.1.10</AssemblyVersion>
<FileVersion>1.10.1.10</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions WDMRC.Console/WDMRC.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<Copyright>[email protected]</Copyright>
<Description>WebDAV emulator for Cloud.mail.ru</Description>
<PackageId>WebDAVCloudMailRu</PackageId>
<AssemblyVersion>1.10.1.9</AssemblyVersion>
<FileVersion>1.10.1.9</FileVersion>
<AssemblyVersion>1.10.1.10</AssemblyVersion>
<FileVersion>1.10.1.10</FileVersion>
<AssemblyName>wdmrc</AssemblyName>
<RootNamespace>YaR.CloudMailRu.Console</RootNamespace>
<StartupObject></StartupObject>
Expand Down

0 comments on commit 84c49dc

Please sign in to comment.