diff --git a/src/Assets/Scripts/Patcher/Patcher.cs b/src/Assets/Scripts/Patcher/Patcher.cs
index 8985ff25..ffa3bb8f 100644
--- a/src/Assets/Scripts/Patcher/Patcher.cs
+++ b/src/Assets/Scripts/Patcher/Patcher.cs
@@ -288,6 +288,12 @@ private void DownloadVersionDiff(int version, ProgressTracker progressTracker, A
foreach (var removedFile in diffSummary.RemovedFiles)
{
+ // Skip directories
+ if (removedFile.EndsWith("/"))
+ {
+ continue;
+ }
+
LogInfo(string.Format("Deleting file {0}", removedFile));
_patcherData.ClearFile(removedFile);
@@ -297,6 +303,23 @@ private void DownloadVersionDiff(int version, ProgressTracker progressTracker, A
patchProgress.Progress = (float)doneFilesCount/totalFilesCount;
}
+ foreach (var removedFile in diffSummary.RemovedFiles)
+ {
+ if (removedFile.EndsWith("/"))
+ {
+ LogInfo(string.Format("Trying to clear directory {0}", removedFile));
+
+ if (_patcherData.TryClearDirectory(removedFile))
+ {
+ LogInfo(string.Format("Succesfuly cleared directory {0}", removedFile));
+ }
+ else
+ {
+ LogInfo(string.Format("Unable to clear directory {0}", removedFile));
+ }
+ }
+ }
+
foreach (var addedFile in diffSummary.AddedFiles)
{
LogInfo(string.Format("Adding file {0}", addedFile));
@@ -317,12 +340,17 @@ private void DownloadVersionDiff(int version, ProgressTracker progressTracker, A
string sourceFilePath = Path.Combine(diffDirectoryPath, addedFile);
- if (Directory.Exists(sourceFilePath))
+ string destinationFilePath = _patcherData.GetFilePath(addedFile);
+
+ string destinationDirPath = Path.GetDirectoryName(destinationFilePath);
+
+ // ReSharper disable once AssignNullToNotNullAttribute
+ if (!Directory.Exists(destinationDirPath))
{
- continue;
+ Directory.CreateDirectory(destinationDirPath);
}
- File.Copy(sourceFilePath, _patcherData.GetFilePath(addedFile), true);
+ File.Copy(sourceFilePath, destinationFilePath, true);
_patcherData.Cache.SetFileVersion(addedFile, version);
diff --git a/src/Assets/Scripts/Patcher/PatcherApplication.cs b/src/Assets/Scripts/Patcher/PatcherApplication.cs
index a7fc9ad7..bb1c971a 100644
--- a/src/Assets/Scripts/Patcher/PatcherApplication.cs
+++ b/src/Assets/Scripts/Patcher/PatcherApplication.cs
@@ -39,7 +39,7 @@ public void StartApplication()
{
foreach(var file in executableApp.GetFiles("*", SearchOption.AllDirectories))
{
- Chmod(file.FullName, "a+x");
+ Chmod(file.FullName, "+x");
}
}
catch (Exception exception)
@@ -51,7 +51,41 @@ public void StartApplication()
processStartInfo.Arguments = string.Format("\"{0}\"", executableApp.FullName);
}
}
- else
+ else if (Application.platform == RuntimePlatform.LinuxPlayer)
+ {
+ var executableFile = directoryInfo.GetDirectories("*", SearchOption.TopDirectoryOnly).Where(info =>
+ {
+ // Read magic bytes
+ using (FileStream executableFileStream = File.OpenRead(info.FullName))
+ {
+ using (BinaryReader executableBinaryReader = new BinaryReader(executableFileStream))
+ {
+ byte[] magicBytes = executableBinaryReader.ReadBytes(4);
+
+ if (magicBytes.Length == 4)
+ {
+ if (magicBytes[0] == 127 && // 7F
+ magicBytes[1] == 69 && // 45 - 'E'
+ magicBytes[2] == 76 && // 4c - 'L'
+ magicBytes[3] == 70) // 46 - 'F'
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }).FirstOrDefault();
+
+ if (executableFile != null)
+ {
+ Chmod(executableFile.FullName, "+x");
+ processStartInfo.FileName = executableFile.FullName;
+ }
+ }
+ else if (Application.platform == RuntimePlatform.WindowsEditor ||
+ Application.platform == RuntimePlatform.WindowsPlayer)
{
var executableFile = directoryInfo.GetFiles("*.exe", SearchOption.TopDirectoryOnly).FirstOrDefault();
diff --git a/src/Assets/Scripts/Patcher/PatcherData.cs b/src/Assets/Scripts/Patcher/PatcherData.cs
index e52311d5..903c9d0e 100644
--- a/src/Assets/Scripts/Patcher/PatcherData.cs
+++ b/src/Assets/Scripts/Patcher/PatcherData.cs
@@ -110,6 +110,30 @@ public void ClearFile(string fileName)
Cache.ClearFileVersion(fileName);
}
+ ///
+ /// Deletes directory if it's possible.
+ ///
+ public bool TryClearDirectory(string directoryName)
+ {
+ string directoryPath = System.IO.Path.Combine(Path, directoryName);
+
+ if (Directory.Exists(directoryPath))
+ {
+ DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
+
+ if (directoryInfo.GetFiles("*", SearchOption.AllDirectories).Length == 0)
+ {
+ Directory.Delete(directoryPath, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
///
/// Returns absolute path to specified file (placed in local data).
///
diff --git a/src/Assets/Scripts/Patcher/UI/ChangelogList.cs b/src/Assets/Scripts/Patcher/UI/ChangelogList.cs
index 4280a751..6848bac1 100644
--- a/src/Assets/Scripts/Patcher/UI/ChangelogList.cs
+++ b/src/Assets/Scripts/Patcher/UI/ChangelogList.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Linq;
using PatchKit.Api;
using PatchKit.Unity.Api;
using PatchKit.Unity.UI;
@@ -27,7 +28,7 @@ protected override IEnumerator RefreshCoroutine()
var versions = ApiConnectionInstance.Instance.EndGetAppVersionList(request);
- foreach (var version in versions)
+ foreach (var version in versions.OrderByDescending(version => version.Id))
{
CreateVersionChangelog(version);
}
diff --git a/src/Assets/Textures/Test Background.png b/src/Assets/Textures/Test Background.png
index 3f57c4c2..74577ffd 100644
Binary files a/src/Assets/Textures/Test Background.png and b/src/Assets/Textures/Test Background.png differ