Пример #1
0
        public void RenameShareByID(string ID, string destinationName)
        {
            RootShare search = shares.Where(s => s.ID == ID).FirstOrDefault();

            if (null != search)
            {
                search.Data.Name = destinationName;
                search.Data.Save(ID);
            }
        }
Пример #2
0
        public void RemoveShareByID(string id)
        {
            RootShare search = shares.Where(s => s.ID == id).FirstOrDefault();

            if (null != search)
            {
                shares.Remove(search);
            }
            string path = SaveLocation + Convert.ToBase64String(Encoding.UTF8.GetBytes(id)) + ".cache";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
        }
Пример #3
0
        public Directory RefreshPath(Share share)
        {
            try
            {
                model.GetAntiShutdownLock();
                lock (share)
                {
                    RootShare rs = shares.Where(s => s.ID == share.ID).FirstOrDefault();
                    if (null == rs)
                    {
                        rs      = new RootShare();
                        rs.ID   = share.ID;
                        rs.Data = new Directory();
                        shares.Add(rs);
                    }
                    rs.Data.Name      = share.Name;
                    rs.Data.Size      = 0;
                    rs.Data.ItemCount = 0;

                    RefreshFileInfo(new DirectoryInfo(share.Path), rs.Data);
                    try
                    {
                        rs.Data.Save(share.ID);
                    }
                    catch (Exception e)
                    {
                        LogManager.GetLogger("faplog").Warn("Failed save share info for " + share.Name, e);
                    }
                    return(rs.Data);
                }
            }
            finally
            {
                model.ReleaseAntiShutdownLock();
            }
        }
Пример #4
0
        public Directory RefreshPath(Share share)
        {
            try
            {
                model.GetAntiShutdownLock();
                lock (share)
                {
                    RootShare rs = shares.Where(s => s.ID == share.ID).FirstOrDefault();
                    if (null == rs)
                    {
                        rs = new RootShare();
                        rs.ID = share.ID;
                        rs.Data = new Directory();
                        shares.Add(rs);
                    }
                    rs.Data.Name = share.Name;
                    rs.Data.Size = 0;
                    rs.Data.ItemCount = 0;

                    RefreshFileInfo(new DirectoryInfo(share.Path), rs.Data);
                    try
                    {
                        rs.Data.Save(share.ID);
                    }
                    catch (Exception e)
                    {
                        LogManager.GetLogger("faplog").Warn("Failed save share info for " + share.Name, e);
                    }
                    return rs.Data;
                }
            }
            finally
            {
                model.ReleaseAntiShutdownLock();
            }
        }