예제 #1
0
            public WasabiRemoteItem(S3Object sourceItem, S3Updater source, string rootFolder)
            {
                _source     = source ?? throw new ArgumentNullException(nameof(source));
                _sourceItem = sourceItem ?? throw new ArgumentNullException(nameof(sourceItem));

                _fullPath = _sourceItem.Key.TrimEnd('/');

                if (rootFolder != null)
                {
                    _rootFolder = rootFolder.TrimEnd('/');
                    if (!_fullPath.StartsWith(_rootFolder))
                    {
                        throw new IOException($"Remote item full path {_fullPath} doesn't start with the specified root path {_rootFolder}");
                    }
                    ClientRelativeFileName = _fullPath.Substring(_rootFolder.Length).Trim('/');
                }

                IsDirectory = IsDirectory(sourceItem);
                if (IsDirectory)
                {
                    throw new ArgumentException("Directory object received in wrong overload");
                }
                IsFile = true;

                ItemSize     = _sourceItem.Size;
                ModifiedTime = _sourceItem.LastModified;
                Name         = Path.GetFileName(_fullPath);
            }
예제 #2
0
            public WasabiRemoteItem(string fullPath, S3Updater source, string rootFolder)
            {
                _source = source ?? throw new ArgumentNullException(nameof(source));

                if (fullPath == null)
                {
                    throw new ArgumentNullException(nameof(fullPath));
                }
                _fullPath = fullPath.TrimEnd('/');

                if (rootFolder != null)
                {
                    _rootFolder = rootFolder.TrimEnd('/');
                    if (!_fullPath.StartsWith(_rootFolder))
                    {
                        throw new IOException($"Remote item full path {_fullPath} doesn't start with the specified root path {_rootFolder}");
                    }
                    ClientRelativeFileName = _fullPath.Substring(_rootFolder.Length).Trim('/');
                }

                IsDirectory = true;

                Name = Path.GetFileName(_fullPath);
            }