コード例 #1
0
        private async Task FinishServeSave(Job job, Guid token)
        {
            try
            {
                await KV.CompleteCheckpointAsync();

                var searchPath = Path.Combine(_options.PersistDirectoryPath, CheckPoints, IndexCheckPoints);

                string[] currentShots = null;


                if (_options.CheckPointType == CheckpointType.Snapshot && Directory.Exists(searchPath))
                {
                    currentShots = Directory
                                   .GetDirectories(searchPath)
                                   .Select(x => Path.GetFileName(x))
                                   .Where(x => x != token.ToString())
                                   .ToArray();
                }

                if (currentShots != null)
                {
                    foreach (var currentShot in currentShots)
                    {
                        Directory.Delete(Path.Combine(_options.PersistDirectoryPath, CheckPoints, CprCheckPoints, currentShot), true);
                        Directory.Delete(Path.Combine(_options.PersistDirectoryPath, CheckPoints, IndexCheckPoints, currentShot), true);
                    }
                }

                job.Complete(false);
            }
            catch (Exception e)
            {
                job.Complete(e);
            }
        }