private void InitServer() { port = FindFreePort(); Debug.WriteLine("port: {0}", port); sessionToken = CreateSessionToken(); // Need to set CWD so the server can read the config file var appFolder = Utils.GetAppFolder(); Directory.SetCurrentDirectory(appFolder); string appDataFolder; try { appDataFolder = ApplicationData.Current.LocalFolder.Path; } catch { var documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); appDataFolder = Path.Combine(documentsFolder, "Focalboard"); Directory.CreateDirectory(appDataFolder); // Not a UWP app, store in Documents // FIXUP code: Copy from old DB location var oldDBPath = Path.Combine(documentsFolder, "focalboard.db"); var newDBPath = Path.Combine(appDataFolder, "focalboard.db"); if (!File.Exists(newDBPath) && File.Exists(oldDBPath)) { Debug.WriteLine($"Moving DB file from: {oldDBPath} to {newDBPath}"); File.Move(oldDBPath, newDBPath); } } var dbPath = Path.Combine(appDataFolder, "focalboard.db"); Debug.WriteLine($"dbPath: {dbPath}"); var filesPath = Path.Combine(appDataFolder, "files"); Debug.WriteLine($"filesPath: {filesPath}"); var cwd = Directory.GetCurrentDirectory(); var webFolder = Path.Combine(cwd, @"pack"); webFolder = webFolder.Replace(@"\", @"/"); filesPath = filesPath.Replace(@"\", @"/"); dbPath = dbPath.Replace(@"\", @"/"); byte[] webFolderBytes = Encoding.UTF8.GetBytes(webFolder); byte[] filesPathBytes = Encoding.UTF8.GetBytes(filesPath); byte[] sessionTokenBytes = Encoding.UTF8.GetBytes(sessionToken); byte[] dbPathBytes = Encoding.UTF8.GetBytes(dbPath); byte[] configFilePathBytes = Encoding.UTF8.GetBytes(""); GoFunctions.StartServer(webFolderBytes, filesPathBytes, port, sessionTokenBytes, dbPathBytes, configFilePathBytes); Debug.WriteLine("Server started"); }
private void InitServer() { port = FindFreePort(); Debug.WriteLine("port: {0}", port); sessionToken = CreateSessionToken(); // Need to set CWD so the server can read the config file var appFolder = Utils.GetAppFolder(); Directory.SetCurrentDirectory(appFolder); string tempFolder; try { tempFolder = ApplicationData.Current.LocalFolder.Path; } catch { var documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); tempFolder = documentsFolder; // Not a UWP app, store in Documents } var dbPath = Path.Combine(tempFolder, "focalboard.db"); Debug.WriteLine($"dbPath: {dbPath}"); var cwd = Directory.GetCurrentDirectory(); var webFolder = Path.Combine(cwd, @"pack"); webFolder = webFolder.Replace(@"\", @"/"); dbPath = dbPath.Replace(@"\", @"/"); byte[] webFolderBytes = Encoding.UTF8.GetBytes(webFolder); byte[] sessionTokenBytes = Encoding.UTF8.GetBytes(sessionToken); byte[] dbPathBytes = Encoding.UTF8.GetBytes(dbPath); GoFunctions.StartServer(webFolderBytes, port, sessionTokenBytes, dbPathBytes); Debug.WriteLine("Server started"); }