public void Cleanup() { foreach (BlendFarmFileSession session in _sessions.Values) { if (session.Networked) { string path = SessionUtil.GetSessionNetworkPath(session.BlendFile, session.SessionID); if (File.Exists(path)) { File.Delete(path); } } } }
/// <summary> /// Updates the file version and copy it to a local directory /// </summary> public long UpdateFileVersion(BlendFarmFileSession session, bool shared) { long oldID = session.FileID; FileInfo info = new FileInfo(session.BlendFile); session.FileID = info.LastWriteTime.Ticks; session.Networked = shared; if (oldID != session.FileID) { if (!shared) { File.Copy(session.BlendFile, session.LocalBlendFile, true); } else { File.Copy(session.BlendFile, SessionUtil.GetSessionNetworkPath(info.FullName, session.SessionID), true); } foreach (RenderNode node in Nodes) { node.UpdateSyncedStatus(session.SessionID, false); } } return(session.FileID); }
public SyncResponse Packet_SyncNetwork(SyncNetworkRequest req) { try { if (!sessions.Contains(req.SessionID)) { sessions.Add(req.SessionID); } SessionData session = SessionData.GetOrCreate(req.SessionID); string uploadID = Guid.NewGuid().ToString(); if (req.FileID != session.FileID) { session.UpdatingFile(); string path = null; switch (SystemInfo.GetOSName()) { case SystemInfo.OS_WINDOWS64: path = req.WindowsPath; break; case SystemInfo.OS_LINUX64: path = req.LinuxPath; break; case SystemInfo.OS_MACOS: path = req.MacOSPath; break; default: throw new NotImplementedException("Unknown OS"); } string sessionPath = SessionUtil.GetSessionNetworkPath(path, req.SessionID); if (!File.Exists(sessionPath)) { throw new InvalidOperationException($"File does not exist [{sessionPath}]"); } session.IsNetworked = true; session.NetworkedPath = sessionPath; session.UpdatedFile(req.FileID); } return(new SyncResponse() { Success = true, SameFile = req.FileID == session.FileID, UploadID = uploadID }); } catch (Exception ex) { return(new SyncResponse() { Success = false, Message = "Failed due to exception:" + ex.Message }); } }