Skip to content

Commit

Permalink
Increase read timeout since we're polling passively now
Browse files Browse the repository at this point in the history
  • Loading branch information
koyuawsmbrtn committed Jan 13, 2024
1 parent eacd340 commit 35a9f20
Showing 1 changed file with 3 additions and 94 deletions.
97 changes: 3 additions & 94 deletions PlaySync/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class Main : Form
bool cansync = false;
bool updateshown = false;
bool autostart = false;
string version = "6";
string version = "7";
string oldtext = "";
string deviceinfo = "";
string[] games;
Expand Down Expand Up @@ -123,7 +123,7 @@ private string sendSerial(string port, string command)
serialPort.Parity = Parity.None;
serialPort.StopBits = StopBits.One;
serialPort.DataBits = 8;
serialPort.ReadTimeout = 20;
serialPort.ReadTimeout = 1000;
try
{
serialPort.Open();
Expand Down Expand Up @@ -654,93 +654,7 @@ private void syncToDevice(object status)

private void syncFromDevice(object callback)
{
try
{
IProgressCallback progress = callback as IProgressCallback;
if (cansync)
{
string gamefolder = config["paths"]["gamefolder"];
string playdatedrive = "";
foreach (var item in System.IO.DriveInfo.GetDrives())
{
if (item.VolumeLabel == "PLAYDATE")
{
playdatedrive = item.Name;
}
}
if (playdatedrive != "")
{
string[] folders = Directory.GetDirectories(playdatedrive);
foreach (string folder in folders)
{
if (folder.Contains("User") || folder.Contains("Seasons") || folder.Contains("Purchased"))
{
try
{
string folderName = folder.Replace(playdatedrive, "");
if (!Directory.Exists(Path.Combine(gamefolder, folderName)))
{
Directory.CreateDirectory(Path.Combine(gamefolder, folderName));
}
foreach (string file in Directory.GetFiles(folder))
{
string fileName = file.Replace(folder + "\\", "");
if (!File.Exists(Path.Combine(gamefolder, folderName, fileName)))
{
File.Copy(file, Path.Combine(gamefolder, folderName, fileName));
}
else
{
if (File.GetLastWriteTime(file) > File.GetLastWriteTime(Path.Combine(gamefolder, folderName, fileName)))
{
File.Copy(file, Path.Combine(gamefolder, folderName, fileName), true);
}
}
}
foreach (string subfolder in Directory.GetDirectories(folder))
{
string subfolderName = subfolder.Replace(folder + "\\", "");
if (!Directory.Exists(Path.Combine(gamefolder, folderName, subfolderName)))
{
Directory.CreateDirectory(Path.Combine(gamefolder, folderName, subfolderName));
}
foreach (string file in Directory.GetFiles(subfolder))
{
string fileName = file.Replace(subfolder + "\\", "");
if (!File.Exists(Path.Combine(gamefolder, folderName, subfolderName, fileName)))
{
File.Copy(file, Path.Combine(gamefolder, folderName, subfolderName, fileName));
}
else
{
if (File.GetLastWriteTime(file) > File.GetLastWriteTime(Path.Combine(gamefolder, folderName, subfolderName, fileName)))
{
File.Copy(file, Path.Combine(gamefolder, folderName, subfolder));
}
}
}
}
}
catch { }
}
}
}
}
progress.End();
ejectPlaydate();
BeginInvoke(new Action(() =>
{
this.Text = title;
}));
}
catch
{
ejectPlaydate();
BeginInvoke(new Action(() =>
{
this.Text = title;
}));
}
throw new NotImplementedException();
}

[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
Expand Down Expand Up @@ -838,11 +752,6 @@ private bool AutoEjectVolume(IntPtr handle)
return DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, IntPtr.Zero, 0, IntPtr.Zero, 0, out byteReturned, IntPtr.Zero);
}

private bool CloseVolume(IntPtr handle)
{
return CloseHandle(handle);
}

private void ejectPlaydate()
{
try
Expand Down

0 comments on commit 35a9f20

Please sign in to comment.