Fixed IO calls in Filebackend.

Moved FileEntry to Library.IO due to AlphaFS not implementing
System.IO.FileInfo/DirectoryInfo.
This commit is contained in:
verhoek
2018-11-01 17:56:48 +01:00
parent 01206a711c
commit 71c6aca8a7
24 changed files with 244 additions and 95 deletions
@@ -27,7 +27,8 @@ using System.Security.Authentication;
using Duplicati.Library.Interface;
using Uri = System.Uri;
using CoreUtility = Duplicati.Library.Utility.Utility;
using Duplicati.Library.IO;
namespace Duplicati.Library.Backend.AlternativeFTP
{
// ReSharper disable once RedundantExtendsListEntry
@@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Duplicati.Library.IO;
using Duplicati.Library.Interface;
using Duplicati.Library.Utility;
using Microsoft.WindowsAzure.Storage;
@@ -79,6 +79,10 @@
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
<Name>Duplicati.Library.Localization</Name>
</ProjectReference>
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
<Name>Duplicati.Library.IO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Duplicati.snk" />
@@ -23,7 +23,8 @@ using System.Linq;
using System.Text;
using System.Net;
using Duplicati.Library.Interface;
using Duplicati.Library.IO;
namespace Duplicati.Library.Backend
{
public class CloudFiles : IBackend, IStreamingBackend
@@ -57,6 +57,10 @@
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
<Name>Duplicati.Library.Localization</Name>
</ProjectReference>
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
<Name>Duplicati.Library.IO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
+3 -2
View File
@@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.IO;
using Duplicati.Library.Interface;
using Duplicati.Library.IO;
namespace Duplicati.Library.Backend
{
public class Dropbox : IBackend, IStreamingBackend
@@ -49,7 +50,7 @@ namespace Duplicati.Library.Backend
get { return "dropbox"; }
}
private FileEntry ParseEntry(MetaData md)
private IFileEntry ParseEntry(MetaData md)
{
var ife = new FileEntry(md.name);
if (md.IsFile)
@@ -61,6 +61,10 @@
<Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
<Name>Duplicati.Library.Localization</Name>
</ProjectReference>
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
<Name>Duplicati.Library.IO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+42 -48
View File
@@ -39,8 +39,9 @@ namespace Duplicati.Library.Backend
private bool m_hasAutenticated;
private readonly bool m_forceReauth;
private readonly byte[] m_copybuffer = new byte[Duplicati.Library.Utility.Utility.DEFAULT_BUFFER_SIZE];
private readonly byte[] m_copybuffer = new byte[Utility.Utility.DEFAULT_BUFFER_SIZE];
private static ISystemIO systemIO = SystemIO.IO_OS(Utility.Utility.IsClientWindows);
public File()
{
@@ -61,12 +62,14 @@ namespace Duplicati.Library.Backend
m_password = uri.Password;
if (!System.IO.Path.IsPathRooted(m_path))
m_path = System.IO.Path.GetFullPath(m_path);
m_path = systemIO.PathGetFullPath(m_path);
if (options.ContainsKey(OPTION_ALTERNATE_PATHS))
{
List<string> paths = new List<string>();
paths.Add(m_path);
List<string> paths = new List<string>
{
m_path
};
paths.AddRange(options[OPTION_ALTERNATE_PATHS].Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries));
//On windows we expand the drive letter * to all drives
@@ -101,7 +104,7 @@ namespace Duplicati.Library.Backend
{
try
{
if (System.IO.Directory.Exists(p) && (markerfile == null || System.IO.File.Exists(System.IO.Path.Combine(p, markerfile))))
if (systemIO.DirectoryExists(p) && (markerfile == null || systemIO.FileExists(systemIO.PathCombine(p, markerfile))))
{
m_path = p;
break;
@@ -125,13 +128,10 @@ namespace Duplicati.Library.Backend
{
try
{
if (!string.IsNullOrEmpty(m_username) && m_password != null)
if (!string.IsNullOrEmpty(m_username) && m_password != null && !m_hasAutenticated)
{
if (!m_hasAutenticated)
{
Win32.PreAuthenticate(m_path, m_username, m_password, m_forceReauth);
m_hasAutenticated = true;
}
Win32.PreAuthenticate(m_path, m_username, m_password, m_forceReauth);
m_hasAutenticated = true;
}
}
catch
@@ -142,10 +142,10 @@ namespace Duplicati.Library.Backend
{
PreAuthenticate();
if (!System.IO.Directory.Exists(m_path))
if (!systemIO.DirectoryExists(m_path))
throw new FolderMissingException(Strings.FileBackend.FolderMissingError(m_path));
return SystemIO.IO_OS(Utility.Utility.IsClientWindows).PathCombine(m_path, remotename);
return systemIO.PathCombine(m_path, remotename);
}
#region IBackendInterface Members
@@ -169,21 +169,17 @@ namespace Duplicati.Library.Backend
{
PreAuthenticate();
if (!System.IO.Directory.Exists(m_path))
if (!systemIO.DirectoryExists(m_path))
throw new FolderMissingException(Strings.FileBackend.FolderMissingError(m_path));
foreach (string s in System.IO.Directory.EnumerateFiles(m_path))
foreach (string s in systemIO.EnumerateFileSystemEntries(m_path))
{
System.IO.FileInfo fi = new System.IO.FileInfo(s);
yield return new FileEntry(fi.Name, fi.Length, fi.LastAccessTime, fi.LastWriteTime);
yield return systemIO.FileEntry(s);
}
foreach (string s in System.IO.Directory.EnumerateDirectories(m_path))
foreach (string s in systemIO.EnumerateDirectories(m_path))
{
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(s);
FileEntry fe = new FileEntry(di.Name, 0, di.LastAccessTime, di.LastWriteTime);
fe.IsFolder = true;
yield return fe;
yield return systemIO.DirectoryEntry(s);
}
}
@@ -191,7 +187,7 @@ namespace Duplicati.Library.Backend
private static Random random = new Random();
public void Put(string remotename, System.IO.Stream stream)
{
using(System.IO.FileStream writestream = System.IO.File.Open(GetRemoteName(remotename), System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
using(System.IO.FileStream writestream = systemIO.FileOpenWrite(GetRemoteName(remotename)))
{
if (random.NextDouble() > 0.6666)
throw new Exception("Random upload failure");
@@ -201,14 +197,15 @@ namespace Duplicati.Library.Backend
#else
public void Put(string remotename, System.IO.Stream stream)
{
using(System.IO.FileStream writestream = System.IO.File.Open(GetRemoteName(remotename), System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
using(System.IO.FileStream writestream = systemIO.FileOpenWrite(GetRemoteName(remotename)))
Utility.Utility.CopyStream(stream, writestream, true, m_copybuffer);
}
#endif
public void Get(string remotename, System.IO.Stream stream)
{
using (System.IO.FileStream readstream = System.IO.File.Open(GetRemoteName(remotename), System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
// FileOpenRead has flags System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read
using (System.IO.FileStream readstream = systemIO.FileOpenRead(GetRemoteName(remotename)))
Utility.Utility.CopyStream(readstream, stream, true, m_copybuffer);
}
@@ -217,23 +214,23 @@ namespace Duplicati.Library.Backend
string path = GetRemoteName(remotename);
if (m_moveFile)
{
if (System.IO.File.Exists(path))
System.IO.File.Delete(path);
if (systemIO.FileExists(path))
systemIO.FileDelete(path);
System.IO.File.Move(filename, path);
systemIO.FileMove(filename, path);
}
else
System.IO.File.Copy(filename, path, true);
systemIO.FileCopy(filename, path, true);
}
public void Get(string remotename, string filename)
{
System.IO.File.Copy(GetRemoteName(remotename), filename, true);
systemIO.FileCopy(GetRemoteName(remotename), filename, true);
}
public void Delete(string remotename)
{
System.IO.File.Delete(GetRemoteName(remotename));
systemIO.FileDelete(GetRemoteName(remotename));
}
public IList<ICommandLineArgument> SupportedCommands
@@ -267,10 +264,10 @@ namespace Duplicati.Library.Backend
public void CreateFolder()
{
if (System.IO.Directory.Exists(m_path))
if (systemIO.DirectoryExists(m_path))
throw new FolderAreadyExistedException();
System.IO.Directory.CreateDirectory(m_path);
systemIO.DirectoryCreate(m_path);
}
#endregion
@@ -278,11 +275,9 @@ namespace Duplicati.Library.Backend
#region IDisposable Members
public void Dispose()
{
if (m_username != null)
m_username = null;
if (m_password != null)
m_password = null;
{
m_username = null;
m_password = null;
}
#endregion
@@ -297,7 +292,7 @@ namespace Duplicati.Library.Backend
string root;
if (Utility.Utility.IsClientLinux)
{
string path = Util.AppendDirSeparator(System.IO.Path.GetFullPath(m_path));
string path = Util.AppendDirSeparator(systemIO.PathGetFullPath(m_path));
root = "/";
//Find longest common prefix from mounted devices
@@ -309,7 +304,7 @@ namespace Duplicati.Library.Backend
}
else
{
root = SystemIO.IO_OS(Utility.Utility.IsClientWindows).GetPathRoot(m_path);
root = systemIO.GetPathRoot(m_path);
}
// On Windows, DriveInfo is only valid for lettered drives. (e.g., not for UNC paths and shares)
@@ -338,16 +333,15 @@ namespace Duplicati.Library.Backend
{
return new QuotaInfo(driveInfo.TotalSize, driveInfo.AvailableFreeSpace);
}
else if (Utility.Utility.IsClientWindows)
if (Utility.Utility.IsClientWindows)
{
// If we can't get the DriveInfo on Windows, fallback to GetFreeDiskSpaceEx
// https://stackoverflow.com/questions/2050343/programmatically-determining-space-available-from-unc-path
return GetDiskFreeSpace(m_path);
}
else
{
return null;
}
return null;
}
}
@@ -360,9 +354,9 @@ namespace Duplicati.Library.Backend
{
var source = GetRemoteName(oldname);
var target = GetRemoteName(newname);
if (System.IO.File.Exists(target))
System.IO.File.Delete(target);
System.IO.File.Move(source, target);
if (systemIO.FileExists(target))
systemIO.FileDelete(target);
systemIO.FileMove(source, target);
}
/// <summary>
@@ -59,6 +59,10 @@
<Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
<Name>Duplicati.Library.Utility</Name>
</ProjectReference>
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
<Name>Duplicati.Library.IO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -19,7 +19,8 @@ using System.Linq;
using System.Collections.Generic;
using Duplicati.Library.Interface;
using CG.Web.MegaApiClient;
using Duplicati.Library.IO;
namespace Duplicati.Library.Backend.Mega
{
public class MegaBackend: IBackend, IStreamingBackend
@@ -10,6 +10,7 @@ using System.Threading;
using Duplicati.Library.Backend.MicrosoftGraph;
using Duplicati.Library.Interface;
using Duplicati.Library.IO;
using Duplicati.Library.Utility;
using Newtonsoft.Json;
@@ -54,6 +54,10 @@
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
<Name>Duplicati.Library.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
<Name>Duplicati.Library.IO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+2 -1
View File
@@ -27,7 +27,8 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Globalization;
using System.IO;
using Duplicati.Library.IO;
namespace Duplicati.Library.Backend
{
public class Rclone : IBackend
+1 -1
View File
@@ -169,7 +169,7 @@ namespace Duplicati.Library.Backend
{
if (alreadyReturned.Add(obj.Key))
{
yield return new FileEntry(
yield return new IO.FileEntry(
obj.Key,
obj.Size,
obj.LastModified,
@@ -58,6 +58,10 @@
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
<Name>Duplicati.Library.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\..\IO\Duplicati.Library.IO.csproj">
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACF}</Project>
<Name>Duplicati.Library.IO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+6 -3
View File
@@ -6,6 +6,7 @@ using System.Net;
using Duplicati.Library.Interface;
using Duplicati.Library.Utility;
using Newtonsoft.Json;
using Duplicati.Library.IO;
namespace Duplicati.Library.Backend.Sia
{
@@ -296,9 +297,11 @@ namespace Duplicati.Library.Backend.Sia
// in our target path
if (f.Siapath.StartsWith(m_targetpath, StringComparison.Ordinal))
{
FileEntry fe = new FileEntry(f.Siapath.Substring(m_targetpath.Length + 1));
fe.Size = f.Filesize;
fe.IsFolder = false;
FileEntry fe = new FileEntry(f.Siapath.Substring(m_targetpath.Length + 1))
{
Size = f.Filesize,
IsFolder = false
};
yield return fe;
}
}
@@ -67,6 +67,7 @@
<Compile Include="Util.cs" />
<Compile Include="DefineDosDevice.cs" />
<Compile Include="WinNativeMethods.cs" />
<Compile Include="FileEntry.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -87,6 +88,10 @@
<Project>{D10A5FC0-11B4-4E70-86AA-8AEA52BD9798}</Project>
<Name>Duplicati.Library.Logging</Name>
</ProjectReference>
<ProjectReference Include="..\Interface\Duplicati.Library.Interface.csproj">
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
<Name>Duplicati.Library.Interface</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\..\..\packages\AlphaVSS.1.4.0\build\net45\AlphaVSS.targets" Condition="Exists('..\..\..\packages\AlphaVSS.1.4.0\build\net45\AlphaVSS.targets')" />
</Project>
@@ -18,10 +18,9 @@
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Interface
namespace Duplicati.Library.IO
{
/// <summary>
/// The primary implementation of the file interface
+13 -5
View File
@@ -18,7 +18,8 @@
using System;
using System.IO;
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.IO
{
/// <summary>
@@ -26,6 +27,7 @@ namespace Duplicati.Library.IO
/// </summary>
public interface ISystemIO
{
IFileEntry DirectoryEntry(string path);
void DirectoryDelete(string path);
void DirectoryDelete(string path, bool recursive);
void DirectoryCreate(string path);
@@ -35,18 +37,21 @@ namespace Duplicati.Library.IO
DateTime DirectoryGetLastWriteTimeUtc(string path);
DateTime DirectoryGetCreationTimeUtc(string path);
IFileEntry FileEntry(string path);
void FileMove(string source, string target);
void FileDelete(string path);
void FileCopy(string source, string target, bool overwrite);
void FileSetLastWriteTimeUtc(string path, DateTime time);
void FileSetCreationTimeUtc(string path, DateTime time);
DateTime FileGetLastWriteTimeUtc(string path);
DateTime FileGetCreationTimeUtc(string path);
bool FileExists(string path);
long FileLength(string path);
Stream FileOpenRead(string path);
Stream FileOpenWrite(string path);
Stream FileOpenReadWrite(string path);
Stream FileCreate(string path);
FileStream FileOpenRead(string path);
FileStream FileOpenWrite(string path);
FileStream FileOpenReadWrite(string path);
FileStream FileCreate(string path);
FileAttributes GetFileAttributes(string path);
void SetFileAttributes(string path, FileAttributes attributes);
void CreateSymlink(string symlinkfile, string target, bool asDir);
@@ -56,6 +61,7 @@ namespace Duplicati.Library.IO
string PathGetExtension(string path);
string PathChangeExtension(string path, string extension);
string PathCombine(params string[] paths);
string PathGetFullPath(string path);
string GetPathRoot(string path);
string[] GetDirectories(string path);
string[] GetFiles(string path);
@@ -63,9 +69,11 @@ namespace Duplicati.Library.IO
DateTime GetCreationTimeUtc(string path);
DateTime GetLastWriteTimeUtc(string path);
IEnumerable<string> EnumerateFileSystemEntries(string path);
IEnumerable<string> EnumerateDirectories(string path);
void SetMetadata(string path, Dictionary<string, string> metdata, bool restorePermissions);
Dictionary<string, string> GetMetadata(string path, bool isSymlink, bool followSymlink);
}
}
+51 -19
View File
@@ -19,7 +19,8 @@ using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.IO
{
public struct SystemIOLinux : ISystemIO
@@ -70,22 +71,22 @@ namespace Duplicati.Library.IO
return File.Exists(path);
}
public Stream FileOpenRead(string path)
public FileStream FileOpenRead(string path)
{
return File.OpenRead(path);
}
public Stream FileOpenWrite(string path)
public FileStream FileOpenWrite(string path)
{
return File.OpenWrite(path);
}
public Stream FileOpenReadWrite(string path)
public FileStream FileOpenReadWrite(string path)
{
return File.Open(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
}
public Stream FileCreate(string path)
public FileStream FileCreate(string path)
{
return File.Create(path);
}
@@ -233,20 +234,6 @@ namespace Duplicati.Library.IO
}
}
}
#endregion
/// <summary>
/// Normalizes a path, by removing any trailing slash, before calling system methods
/// </summary>
/// <returns>The path to normalize.</returns>
/// <param name="path">The normalized path.</param>
public static string NormalizePath(string path)
{
var p = Path.GetFullPath(path);
// This should not be required, but some versions of Mono apperently do not strip the trailing slash
return p.Length > 1 && p[p.Length - 1] == Path.DirectorySeparatorChar ? p.Substring(0, p.Length - 1) : p;
}
public string GetPathRoot(string path)
{
@@ -276,7 +263,52 @@ namespace Duplicati.Library.IO
public DateTime GetLastWriteTimeUtc(string path)
{
return File.GetLastWriteTimeUtc(path);
}
public IEnumerable<string> EnumerateDirectories(string path)
{
return Directory.EnumerateDirectories(path);
}
public void FileCopy(string source, string target, bool overwrite)
{
File.Copy(source, target, overwrite);
}
public string PathGetFullPath(string path)
{
return Path.GetFullPath(path);
}
#endregion
/// <summary>
/// Normalizes a path, by removing any trailing slash, before calling system methods
/// </summary>
/// <returns>The path to normalize.</returns>
/// <param name="path">The normalized path.</param>
public static string NormalizePath(string path)
{
var p = Path.GetFullPath(path);
// This should not be required, but some versions of Mono apperently do not strip the trailing slash
return p.Length > 1 && p[p.Length - 1] == Path.DirectorySeparatorChar ? p.Substring(0, p.Length - 1) : p;
}
public IFileEntry DirectoryEntry(string path)
{
var dInfo = new DirectoryInfo(path);
return new FileEntry(dInfo.Name, 0, dInfo.LastAccessTime, dInfo.LastWriteTime)
{
IsFolder = true
};
}
public IFileEntry FileEntry(string path)
{
var fileInfo = new FileInfo(path);
return new FileEntry(fileInfo.Name, fileInfo.Length, fileInfo.LastAccessTime, fileInfo.LastWriteTime);
}
}
}
+83 -6
View File
@@ -22,7 +22,7 @@ using System.IO;
using Alphaleonis.Win32.Vss;
using AlphaFS = Alphaleonis.Win32.Filesystem;
using Duplicati.Library.Interface;
namespace Duplicati.Library.IO
{
@@ -180,7 +180,7 @@ namespace Duplicati.Library.IO
return Alphaleonis.Win32.Filesystem.File.Exists(PrefixWithUNC(path));
}
public System.IO.Stream FileOpenRead(string path)
public System.IO.FileStream FileOpenRead(string path)
{
if (!IsPathTooLong(path))
try { return System.IO.File.Open(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite); }
@@ -190,7 +190,7 @@ namespace Duplicati.Library.IO
return Alphaleonis.Win32.Filesystem.File.Open(PrefixWithUNC(path), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
}
public System.IO.Stream FileOpenWrite(string path)
public System.IO.FileStream FileOpenWrite(string path)
{
if (!IsPathTooLong(path))
try { return System.IO.File.OpenWrite(path); }
@@ -203,7 +203,7 @@ namespace Duplicati.Library.IO
return FileCreate(path);
}
public System.IO.Stream FileOpenReadWrite(string path)
public System.IO.FileStream FileOpenReadWrite(string path)
{
if (!IsPathTooLong(path))
try { return System.IO.File.Open(path, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.Read); }
@@ -213,7 +213,7 @@ namespace Duplicati.Library.IO
return Alphaleonis.Win32.Filesystem.File.Open(PrefixWithUNC(path), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
}
public System.IO.Stream FileCreate(string path)
public System.IO.FileStream FileCreate(string path)
{
if (!IsPathTooLong(path))
try { return System.IO.File.Create(path); }
@@ -699,7 +699,84 @@ namespace Duplicati.Library.IO
}
return AlphaFS.File.GetLastWriteTimeUtc(path);
}
}
public IEnumerable<string> EnumerateDirectories(string path)
{
if (!IsPathTooLong(path))
{
try { return Directory.EnumerateDirectories(path); }
catch (System.IO.PathTooLongException) { }
catch (System.ArgumentException) { }
}
return AlphaFS.Directory.EnumerateDirectories(path);
}
public void FileCopy(string source, string target, bool overwrite)
{
if (!IsPathTooLong(source) && !IsPathTooLong(target))
{
try { File.Copy(source, target, overwrite); }
catch (System.IO.PathTooLongException) { }
catch (System.ArgumentException) { }
}
AlphaFS.File.Copy(source, target, overwrite);
}
public string PathGetFullPath(string path)
{
if (!IsPathTooLong(path))
{
try { return System.IO.Path.GetFullPath(path); }
catch (System.IO.PathTooLongException) { }
catch (System.ArgumentException) { }
}
return AlphaFS.Path.GetFullPath(path);
}
public IFileEntry DirectoryEntry(string path)
{
if (!IsPathTooLong(path))
{
try
{
var dInfo = new DirectoryInfo(path);
return new FileEntry(dInfo.Name, 0, dInfo.LastAccessTime, dInfo.LastWriteTime)
{
IsFolder = true
};
}
catch (System.IO.PathTooLongException) { }
catch (System.ArgumentException) { }
}
var dInfoAlphaFS = new AlphaFS.DirectoryInfo(path);
return new FileEntry(dInfoAlphaFS.Name, 0, dInfoAlphaFS.LastAccessTime, dInfoAlphaFS.LastWriteTime)
{
IsFolder = true
};
}
public IFileEntry FileEntry(string path)
{
if (!IsPathTooLong(path))
{
try
{
var fileInfo = new FileInfo(path);
return new FileEntry(fileInfo.Name, fileInfo.Length, fileInfo.LastAccessTime, fileInfo.LastWriteTime);
}
catch (System.IO.PathTooLongException) { }
catch (System.ArgumentException) { }
}
var fInfoAlphaFS = new AlphaFS.FileInfo(path);
return new FileEntry(fInfoAlphaFS.Name, fInfoAlphaFS.Length, fInfoAlphaFS.LastAccessTime, fInfoAlphaFS.LastWriteTime);
}
#endregion
}
}
@@ -45,7 +45,6 @@
<Compile Include="CommandLineArgument.cs" />
<Compile Include="CommonStrings.cs" />
<Compile Include="CustomExceptions.cs" />
<Compile Include="FileEntry.cs" />
<Compile Include="IBackend.cs" />
<Compile Include="USNJournalDataEntry.cs" />
<Compile Include="ICommandLineArgument.cs" />
@@ -209,7 +209,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
var systemIO = SystemIO.IO_OS(Library.Utility.Utility.IsClientWindows);
foreach (var s in System.IO.Directory.EnumerateFileSystemEntries(entrypath))
foreach (var s in systemIO.EnumerateFileSystemEntries(entrypath))
{
Serializable.TreeNode tn = null;
try
+3 -2
View File
@@ -19,7 +19,8 @@ using System.Linq;
using Duplicati.Library.Interface;
using System.Collections.Generic;
using System.IO;
using Duplicati.Library.IO;
namespace Duplicati.UnitTest
{
public class SizeOmittingBackend : IBackend, IStreamingBackend
@@ -56,7 +57,7 @@ namespace Duplicati.UnitTest
return
from n in m_backend.List()
where !n.IsFolder
select new Library.Interface.FileEntry(n.Name);
select new FileEntry(n.Name);
}
public void Put(string remotename, string filename)
{