enforced file system
This commit is contained in:
parent
bdd4cf2472
commit
6066497a67
26 changed files with 143 additions and 76 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Yavsc.Abstract.FileSystem
|
||||
{
|
||||
|
|
@ -6,20 +7,35 @@ namespace Yavsc.Abstract.FileSystem
|
|||
{
|
||||
public static bool IsValidYavscPath(this string path)
|
||||
{
|
||||
if (path == null) return true;
|
||||
if (string.IsNullOrEmpty(path)) return true;
|
||||
foreach (var name in path.Split('/'))
|
||||
{
|
||||
if (!IsValidDirectoryName(name) || name.Equals("..") || name.Equals("."))
|
||||
return false;
|
||||
}
|
||||
if (path[path.Length]==FileSystemConstants.RemoteDirectorySeparator) return false;
|
||||
if (path[path.Length-1]==FileSystemConstants.RemoteDirectorySeparator) return false;
|
||||
return true;
|
||||
}
|
||||
public static bool IsValidDirectoryName(this string name)
|
||||
{
|
||||
return !name.Any(c => !FileSystemConstants.ValidFileNameChars.Contains(c));
|
||||
}
|
||||
// Ensure this path is canonical,
|
||||
// No "dirto/./this", neither "dirt/to/that/"
|
||||
// no .. and each char must be listed as valid in constants
|
||||
|
||||
public static string FilterFileName(string fileName)
|
||||
{
|
||||
if (fileName==null) return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var c in fileName)
|
||||
{
|
||||
if (FileSystemConstants.ValidFileNameChars.Contains(c))
|
||||
sb.Append(c);
|
||||
else sb.Append('_');
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FileSystemConstants
|
||||
|
|
|
|||
8
Yavsc.Abstract/FileSystem/IDirectoryShortInfo.cs
Normal file
8
Yavsc.Abstract/FileSystem/IDirectoryShortInfo.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace Yavsc.Abstract.FileSystem {
|
||||
|
||||
public interface IDirectoryShortInfo
|
||||
{
|
||||
string Name { get; set; }
|
||||
bool IsEmpty { get; set; }
|
||||
}
|
||||
}
|
||||
15
Yavsc.Abstract/FileSystem/IFileRecieved.Info.cs
Normal file
15
Yavsc.Abstract/FileSystem/IFileRecieved.Info.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
namespace Yavsc.Abstract.FileSystem
|
||||
{
|
||||
public interface IFileRecievedInfo
|
||||
{
|
||||
string MimeType { get; set; }
|
||||
|
||||
string DestDir { get; set; }
|
||||
|
||||
string FileName { get; set; }
|
||||
|
||||
bool Overriden { get; set; }
|
||||
|
||||
bool QuotaOffensed { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -7,15 +7,21 @@ namespace Yavsc.ViewModels.UserFiles
|
|||
{
|
||||
public class UserDirectoryInfo
|
||||
{
|
||||
public string UserName { get; private set; }
|
||||
public string SubPath { get; private set; }
|
||||
public string UserName { get; set; }
|
||||
public string SubPath { get; set; }
|
||||
public RemoteFileInfo [] Files {
|
||||
get; private set;
|
||||
get; set;
|
||||
}
|
||||
public string [] SubDirectories {
|
||||
get; private set;
|
||||
public DirectoryShortInfo [] SubDirectories {
|
||||
get; set;
|
||||
}
|
||||
private DirectoryInfo dInfo;
|
||||
|
||||
// for deserialization
|
||||
public UserDirectoryInfo()
|
||||
{
|
||||
|
||||
}
|
||||
public UserDirectoryInfo(string userReposPath, string username, string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
|
|
@ -35,7 +41,12 @@ namespace Yavsc.ViewModels.UserFiles
|
|||
( entry => new RemoteFileInfo { Name = entry.Name, Size = entry.Length,
|
||||
CreationTime = entry.CreationTime, LastModified = entry.LastWriteTime }).ToArray();
|
||||
SubDirectories = dInfo.GetDirectories().Select
|
||||
( d=> d.Name ).ToArray();
|
||||
( d=> new DirectoryShortInfo { Name= d.Name, IsEmpty=false } ).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public class DirectoryShortInfo: IDirectoryShortInfo {
|
||||
public string Name { get; set; }
|
||||
public bool IsEmpty { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
CONFIG=Release
|
||||
VERSION=1.0.2
|
||||
VERSION=1.0.5-rc4
|
||||
PRJNAME=Yavsc.Abstract
|
||||
PKGFILENAME=$(PRJNAME).$(VERSION).nupkg
|
||||
DESTPATH=.
|
||||
PACKAGE=$(DESTPATH)/$(PKGFILENAME)
|
||||
BINARY=bin/$(CONFIG)/net45/Yavsc.Abstract.dll
|
||||
NUGETSOURCE=$(HOME)/Nupkgs/
|
||||
|
||||
$(PACKAGE):
|
||||
nuget pack $(PRJNAME).nuspec -Version $(VERSION)
|
||||
|
||||
publish: $(PACKAGE)
|
||||
cp $(PACKAGE) ~/Nupkgs
|
||||
$(PACKAGE): $(BINARY)
|
||||
nuget pack $(PRJNAME).nuspec -Version $(VERSION) -Properties config=$(CONFIG)
|
||||
|
||||
clean:
|
||||
rm $(PACKAGE)
|
||||
|
||||
$(BINARY): project.lock.json
|
||||
dnu build --configuration $(CONFIG)
|
||||
|
||||
project.lock.json: project.json
|
||||
dnu restore
|
||||
|
||||
deploy: $(PACKAGE)
|
||||
cp $(PACKAGE) $(NUGETSOURCE)
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ using System.Reflection;
|
|||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Yavsc.Client")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyTitle("Yavsc.Abstract")]
|
||||
[assembly: AssemblyDescription("Yavsc shared objects")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Yavsc.Client")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyProduct("Yavsc.Abstract")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014-2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
[assembly: NeutralResourcesLanguage("fr")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
|
|
@ -24,5 +24,5 @@ using System.Reflection;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.5.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.5.2")]
|
||||
|
|
|
|||
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.0.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.0.nupkg
Normal file
Binary file not shown.
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.3.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.3.nupkg
Normal file
Binary file not shown.
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.4.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.4.nupkg
Normal file
Binary file not shown.
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc1.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc1.nupkg
Normal file
Binary file not shown.
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc2.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc2.nupkg
Normal file
Binary file not shown.
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc3.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc3.nupkg
Normal file
Binary file not shown.
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc4.nupkg
Normal file
BIN
Yavsc.Abstract/Yavsc.Abstract.1.0.5-rc4.nupkg
Normal file
Binary file not shown.
|
|
@ -18,6 +18,6 @@
|
|||
<tags>yavsc</tags>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="bin/Release/net451/Yavsc.Abstract.dll" target="lib/portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10" />
|
||||
<file src="bin/$config$/net451/Yavsc.Abstract.dll" target="lib/portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10" />
|
||||
</files>
|
||||
</package>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.5",
|
||||
"description": "Yavsc Client Api",
|
||||
"authors": [
|
||||
"Paul Schneider"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue