[BUG] Legacy Issues
TheYellowArchitect opened this issue · 2 comments
I am using Unity 2018.1.f1, Windows 7, ParrelSync 1.4.1
Error: "Symbolic Links cannot be used because it is not part of the C# 4.0 language specification"
The bug is at https://github.com/VeriorPies/ParrelSync/blob/master/ParrelSync/Editor/ClonesManager.cs#L301
The fix is obvious
var command = "ln -s " + sourcePath + " " + destinationPath;
and no matter what I do, after I fix it, I get a bunch of errors, probably related to my legacy stuff
Like, Path.Combine taking 3 arguments, and my library can take only up to 2.
Image below is all errors I get. Is there an alternative for that code?
For example, Path.Combine(x,y,z) can be Path.Combine(x,Path.Combine(y,z))
Update:
- Path.Combine now works
string UnityLockFilePath = Path.Combine(projectPath, "Temp", "UnityLockfile");
to
string UnityLockFilePath = Path.Combine(projectPath, Path.Combine("Temp", "UnityLockfile"));
string.Join(separator[0].ToString(), pathArray);
to
for (int i = 0; i < pathArray.Count; i++) rootPath = rootPath + separator[0].ToString() + pathArray[i];
Is this correct?- On .NET 5.0+ DirectoryInfo https://github.com/VeriorPies/ParrelSync/blob/master/ParrelSync/Editor/ClonesManager.cs#L568, here is what I did:
private static long GetDirectorySize(DirectoryInfo directory, bool includeNested = false, string progressBarPrefix = "")
{
EditorUtility.DisplayProgressBar(progressBarPrefix + "Calculating size of directories...",
"Scanning '" + directory.FullName + "'...", 0f);
/// Calculate size of all files in directory.
long filesSize = GetLocalDirectorySize(directory.FullName);
/// Calculate size of all nested directories.
long directoriesSize = 0;
if (includeNested)
{
List<DirectoryInfo> nestedDirectories = new List<DirectoryInfo>(directory.GetDirectories());
foreach (DirectoryInfo nestedDir in nestedDirectories)
{
directoriesSize += ClonesManager.GetDirectorySize(nestedDir, true, progressBarPrefix);
}
}
return filesSize + directoriesSize;
}
static long GetLocalDirectorySize(string p)
{
// 1. Get array of all file names.
string[] a = Directory.GetFiles(p, "*.*");
// 2. Calculate total bytes of all files in a loop.
long b = 0;
foreach (string name in a)
{
// 3. Use FileInfo to get length of each file.
FileInfo info = new FileInfo(name);
b += info.Length;
}
// 4. Return total size
return b;
}
If my hacky edits work, I will close this issue (and hopefully take the time to push them, with an #if_.NET_4.0 declaration)
The above seem to work, as my ParrelSync runs finely.
I will push them when I find the time
However, can someone confirm, the above work? Not run the code, but manually skim the code and confirm for any logic errors
Because, for example, in the GetDirectorySize - that is all for visuals I think (progress bar), so if I am wrong, I may be running buggy behaviour (and push that onto development fork