Ejemplo n.º 1
0
        private bool DeleteFile(string path, IReadOnlyList <string> pathSegments)
        {
            if (!filesInfo.Delete(pathSegments, 0))
            {
                return(false);
            }

            changes.OnNext(FileChangedEvent.Deleted(path));
            log.TraceFormat("File {Path} was deleted", path);
            return(true);
        }
Ejemplo n.º 2
0
        private void CreateOrUpdateFile(string path, IReadOnlyList <string> pathSegments)
        {
            var lastWriteTime = File.GetLastWriteTimeUtc(path);

            if (lastWriteTime == NonExistingWriteTimeUtc)
            {
                log.TraceFormat("File {Path} is not exist");
                return;
            }

            if (filesInfo.TryGetData(pathSegments, 0, out var fileInfo) && lastWriteTime == fileInfo.LastWriteTime)
            {
                log.TraceFormat("File {Path} was not updated", path);
                return;
            }

            filesInfo.Add(pathSegments, 0, new FileInfo(path, lastWriteTime));
            changes.OnNext(FileChangedEvent.CreatedOrUpdated(path));
            log.TraceFormat("File {Path} was created or updated", path);
        }