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); } }
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); } }
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(); } }
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(); } }