From 3df69fc5e63ff886693ffcf25bc58d51ec44efbc Mon Sep 17 00:00:00 2001 From: Rostislav Kirillov Date: Mon, 22 Feb 2021 20:54:47 +0500 Subject: [PATCH] fix missing cache file; add video urls #3 --- VOffline/Services/Storage/FilesystemTools.cs | 5 +++++ VOffline/Services/Vk/AttachmentExtensions.cs | 5 ++++- VOffline/VOffline.csproj | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/VOffline/Services/Storage/FilesystemTools.cs b/VOffline/Services/Storage/FilesystemTools.cs index 6cd2ffc..01e564c 100644 --- a/VOffline/Services/Storage/FilesystemTools.cs +++ b/VOffline/Services/Storage/FilesystemTools.cs @@ -27,6 +27,11 @@ namespace VOffline.Services.Storage RootDir = MkDir(settings.Value.OutputPath); cacheFile = new FileInfo(CombineCutPath(RootDir, CacheFilename)); cache = new ConcurrentDictionary(); + + if (!cacheFile.Exists) + { + cacheFile.Create()?.Dispose(); + } } public void LoadCache(ILog log) diff --git a/VOffline/Services/Vk/AttachmentExtensions.cs b/VOffline/Services/Vk/AttachmentExtensions.cs index 786dab2..80841dc 100644 --- a/VOffline/Services/Vk/AttachmentExtensions.cs +++ b/VOffline/Services/Vk/AttachmentExtensions.cs @@ -94,7 +94,9 @@ namespace VOffline.Services.Vk } else { - log.Warn($"Video {video.Id} [{video.Title}] has no links"); + log.Warn($"Video {video.Id} [{video.Title}] has no links. Trying to compose vk url"); + var file = filesystemTools.CreateFile(dir, $"{i} {video.Id}.txt", CreateMode.OverwriteExisting); + File.WriteAllText(file.FullName, $"https://vk.com/video{video.OwnerId}_{video.Id}"); } } @@ -201,6 +203,7 @@ namespace VOffline.Services.Vk { sb.Append($", reply to user {comment.ReplyToUserId} comment {comment.ReplyToCommentId}"); } + return sb.ToString(); } diff --git a/VOffline/VOffline.csproj b/VOffline/VOffline.csproj index 9a74614..074befc 100644 --- a/VOffline/VOffline.csproj +++ b/VOffline/VOffline.csproj @@ -3,8 +3,9 @@ Exe netcoreapp2.1 - 26938AF3-7336-429C-A3AF-2D3048ACB226 latest + VOffline + 93680df2-87fc-4326-b623-001d5725f6ae