Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions src/RagnaCustoms.App/Services/AndroidDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static int SyncSongs()
catch (Exception except)
{
syncingView.Close();
MessageBox.Show($"Error: {except.Message}", "RagnaCutoms", MessageBoxButtons.OK,
MessageBox.Show($"Error: {except.Message}", "RagnaCustoms", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return 3;
}
Expand All @@ -112,25 +112,36 @@ public static int SyncSongs()

public static int PushSong(string path)
{
var device = GetFirstFoundDevice();
if (device != null)
try
{
var song = path.Split(Path.DirectorySeparatorChar).Last();
device.Connect();
var baseFolder = device.GetDirectories(@"\")[0];
var questSongDirectoryPath = $"{baseFolder}{DeviceSongDirectoryName}\\{song}";
var device = GetFirstFoundDevice();
if (device != null)
{
var song = path.Split(Path.DirectorySeparatorChar).Last();
device.Connect();
var baseFolder = device.GetDirectories(@"\")[0];
var questSongDirectoryPath = $"{baseFolder}{DeviceSongDirectoryName}\\{song}";

if (!device.IsConnected) throw new NotConnectedException("Not connected");
if (!device.IsConnected) throw new NotConnectedException("Not connected");

if (device.DirectoryExists(questSongDirectoryPath))
device.DeleteDirectory(questSongDirectoryPath, true);
if (device.DirectoryExists(questSongDirectoryPath))
device.DeleteDirectory(questSongDirectoryPath, true);

device.CreateDirectory(questSongDirectoryPath);
device.CreateDirectory(questSongDirectoryPath);

device.UploadFolder(path, questSongDirectoryPath);
device.Disconnect();
device.UploadFolder(path, questSongDirectoryPath);
device.Disconnect();

return 0;
return 0;
}
}
catch(NotConnectedException nex)
{
throw;
}
catch (Exception ex)
{
return 1;
}

return 1;
Expand Down