mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-28 06:34:49 +00:00
Code freeze
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using OpenMetaverse.ImportExport.Collada14;
|
||||
using OpenMetaverse;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using SearchOption = System.IO.SearchOption;
|
||||
|
||||
// on every boot, as soon as possible,
|
||||
// copy any missing/changed items in streaming assets to the data path in user-accessible-space
|
||||
@@ -11,7 +11,7 @@ namespace Disk
|
||||
{
|
||||
public class CopyStreamingAssetsToPersistentDataPath : MonoBehaviour
|
||||
{
|
||||
[FormerlySerializedAs("doneCopy")] public bool copyIsDone = false;
|
||||
public bool copyIsDone = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -23,45 +23,59 @@ namespace Disk
|
||||
|
||||
private void CheckOmvDataFolderAndUpdateItIfNecessary()
|
||||
{
|
||||
List<string> updatedFiles = ScanAndCopy_StreamingAssetsFolder(
|
||||
List<string> updatedFiles = CopyIfRequired_StreamingAssetsFolder(
|
||||
DirectoryHelpers.GetInternalCacheDir()
|
||||
);
|
||||
|
||||
if (updatedFiles.Count > 0)
|
||||
{
|
||||
var printString = String.Join(Environment.NewLine, updatedFiles);
|
||||
Debug.Log("there were some updates to staticAssets in : "
|
||||
+ Environment.NewLine
|
||||
+ printString);
|
||||
OpenMetaverse.Logger.Log(
|
||||
"These files were copied from staticAssets : "
|
||||
+ Environment.NewLine
|
||||
+ printString,
|
||||
Helpers.LogLevel.Info
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("staticAssets are already latest version in : "
|
||||
+ DirectoryHelpers.GetInternalCacheDir());
|
||||
OpenMetaverse.Logger.Log(
|
||||
"staticAssets are already latest version in : "
|
||||
+ DirectoryHelpers.GetInternalCacheDir(),
|
||||
Helpers.LogLevel.Info
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// scan all files in streamingAssets folder, and copy any changed/missing files into userDataRoot.
|
||||
// return true if some file was updated.
|
||||
private List<string> ScanAndCopy_StreamingAssetsFolder(string appRootPath)
|
||||
private List<string> CopyIfRequired_StreamingAssetsFolder(string appRootPath)
|
||||
{
|
||||
List<String> updatedFiles = new List<string>();
|
||||
// bool someFileWasUpdated = false;
|
||||
|
||||
|
||||
//everything in StreamingAssets\
|
||||
Debug.Assert( BetterStreamingAssets.DirectoryExists("\\") );
|
||||
string[] paths = BetterStreamingAssets.GetFiles("\\", "*", SearchOption.AllDirectories);
|
||||
string slash = Path.DirectorySeparatorChar.ToString();
|
||||
if (!BetterStreamingAssets.DirectoryExists(slash))
|
||||
{
|
||||
throw new Exception("StreamingAssets root not accessible.");
|
||||
}
|
||||
string[] paths = BetterStreamingAssets.GetFiles(slash, "*", SearchOption.AllDirectories);
|
||||
|
||||
if (paths.Length == 0)
|
||||
{
|
||||
throw new Exception("StreamingAssets has no files in it.");
|
||||
}
|
||||
foreach (var sourcePath in paths)
|
||||
{
|
||||
string relativePath = "";
|
||||
|
||||
//find the equivalent path in appRootPath
|
||||
string root = Directory.GetDirectoryRoot(sourcePath); // this is \StreamingAssets\, which we wish to remove.
|
||||
string root = Directory.GetDirectoryRoot(sourcePath);
|
||||
if (root != null/*todo: check for failed get root.*/)
|
||||
{
|
||||
relativePath = sourcePath.Substring(root.Length - 1); // gotta remove that \
|
||||
// gotta remove that root slash character '\'
|
||||
relativePath = sourcePath.Substring(root.Length - 1);
|
||||
}
|
||||
|
||||
string targetPath = Path.Combine(appRootPath, relativePath);
|
||||
|
||||
Reference in New Issue
Block a user