Exemple #1
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var user = await _context.Users.SingleOrDefaultAsync(x => x.UserName == _userAccessor.GetCurrentUsername());

                if (user == null || (user.Rank != AppUserRank.Editor && user.Rank != AppUserRank.Admin))
                {
                    throw new RestException(HttpStatusCode.Unauthorized);
                }

                var dict = await GetSubTree(request.Ids);

                FSObject fs = null;

                foreach (var item in dict)
                {
                    fs = item.Value;
                    if (fs.Type != FSType.FOLDER && fs.Url != null)
                    {
                        System.IO.File.Delete(FSObjectConfig.BaseFolderName + "/" + fs.Url);
                    }
                }

                var list = dict.Values.ToList();

                _context.FSObjects.RemoveRange(list);

                if (await _context.SaveChangesAsync() == 0)
                {
                    throw new RestException(HttpStatusCode.InternalServerError, new { FSObject = "Problem saving changes" });
                }

                return(Unit.Value);
            }
Exemple #2
0
        private void AddToWatch(FSObject dir)
        {
            if (!dir.IsDir())
            {
                return;
            }

            if (IsWatching(dir))
            {
                return;
            }

            WatchDirs.Add(dir);
        }
Exemple #3
0
        private void MakePath(string path)
        {
            CurrentDirPath = new LinkedList <FSObject>();
            var items = CurrentDirPath;

            if (path != "root")
            {
                DirectoryInfo dir = new DirectoryInfo(path);

                while (dir != null)
                {
                    items.AddFirst(new FSObject(dir));

                    dir = dir.Parent;
                }
            }

            items.AddFirst(FSObject.Root());
        }
Exemple #4
0
        public static bool Exist(string path, FSObject type = FSObject.File)
        {
            var b = false;

            switch (type)
            {
            case FSObject.File:
                b = File.Exists(path);
                break;

            case FSObject.Directory:
                b = Directory.Exists(path);
                break;

            default:
                b = false;
                break;
            }

            return(b);
        }
Exemple #5
0
 private void RemoveFromWatch(FSObject dir)
 {
 }
Exemple #6
0
 private bool IsWatching(FSObject dir)
 {
     return(WatchDirs.Any(i => i.FullPath == dir.FullPath));
 }