示例#1
0
        internal async Task BackgroundTask(string subPath, string operationId)
        {
            var operationHolder = RequestTelemetryHelper.GetOperationHolder(_scopeFactory,
                                                                            nameof(ManualSync), operationId);

            _logger.LogInformation($"[ManualBackgroundSyncService] start {subPath} " +
                                   $"{DateTime.Now.ToShortTimeString()}");

            var updatedList = await _synchronize.Sync(subPath, false, PushToSockets);

            _query.CacheUpdateItem(updatedList.Where(p => p.ParentDirectory == subPath).ToList());

            // so you can click on the button again
            _cache.Remove(ManualSyncCacheName + subPath);
            _logger.LogInformation($"[ManualBackgroundSyncService] done {subPath} " +
                                   $"{DateTime.Now.ToShortTimeString()}");
            _logger.LogInformation($"[ManualBackgroundSyncService] Ok: {updatedList.Count(p => p.Status == FileIndexItem.ExifStatus.Ok)}" +
                                   $" ~ OkAndSame: {updatedList.Count(p => p.Status == FileIndexItem.ExifStatus.OkAndSame)}");
            operationHolder.SetData(_scopeFactory, updatedList);
        }
示例#2
0
文件: SyncCli.cs 项目: qdraw/starsky
        public async Task Sync(string[] args)
        {
            _appSettings.Verbose         = ArgsHelper.NeedVerbose(args);
            _appSettings.ApplicationType = AppSettings.StarskyAppType.Sync;

            if (new ArgsHelper().NeedHelp(args))
            {
                new ArgsHelper(_appSettings, _console).NeedHelpShowDialog();
                return;
            }

            new ArgsHelper().SetEnvironmentByArgs(args);

            var subPath            = new ArgsHelper(_appSettings).SubPathOrPathValue(args);
            var getSubPathRelative = new ArgsHelper(_appSettings).GetRelativeValue(args);

            if (getSubPathRelative != null)
            {
                subPath = new StructureService(_selectorStorage.Get(SelectorStorage.StorageServices.SubPath), _appSettings.Structure)
                          .ParseSubfolders(getSubPathRelative);
            }

            if (new ArgsHelper().GetIndexMode(args))
            {
                var stopWatch = Stopwatch.StartNew();
                _console.WriteLine($"Start indexing {subPath}");
                var result = await _synchronize.Sync(subPath);

                if (result.All(p => p.FilePath != subPath))
                {
                    _console.WriteLine($"Not Found: {subPath}");
                }
                _console.WriteLine($"\nDone SyncFiles! (in sec: {Math.Round(stopWatch.Elapsed.TotalSeconds, 1)})");
            }
            _console.WriteLine("Done!");
        }