Skip to content

Commit

Permalink
Merge branch '3.x' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge authored Jan 15, 2022
2 parents a5cb83b + adafbfb commit bcee2f4
Show file tree
Hide file tree
Showing 51 changed files with 677 additions and 259 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish-subsplits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Sub-Split Publishing
on:
push:
branches:
- 2.x
- 3.x
create:
tags:
- '*'
- '3.*'
delete:
tags:
- '*'
- '3.*'

jobs:
publish_subsplits:
Expand All @@ -33,7 +33,7 @@ jobs:
key: '${{ runner.os }}-splitsh'
- uses: frankdejonge/[email protected]
with:
source-branch: '2.x'
source-branch: '3.x'
config-path: './config.subsplit-publish.json'
splitsh-path: './.splitsh/splitsh-lite'
splitsh-version: 'v1.0.1'
18 changes: 3 additions & 15 deletions .github/workflows/quality-assurance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ on:
- src/**/*.php
- .github/workflows/quality-assurance.yml
branches:
- 2.x
- 3.x
pull_request:
paths:
- src/**/*.php
- .github/workflows/quality-assurance.yml
branches:
- 2.x
- 3.x

env:
FLYSYSTEM_AWS_S3_KEY: '${{ secrets.FLYSYSTEM_AWS_S3_KEY }}'
Expand All @@ -29,23 +30,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4' ]
php: [ '8.0', '8.1' ]
composer-flags: [ '' ]
experimental: [false]
upgrade-aws-sdk: [ 'no' ]
phpunit-flags: [ '--coverage-text' ]
include:
- php: '8.0'
composer-flags: ''
experimental: false
phpunit-flags: '--no-coverage'
upgrade-aws-sdk: 'yes'
- php: '8.1'
composer-flags: '--ignore-platform-reqs'
experimental: true
phpunit-flags: '--no-coverage'
upgrade-aws-sdk: 'yes'
- php: '7.2'
composer-flags: '--prefer-lowest'
experimental: false
phpunit-flags: '--no-coverage'
Expand All @@ -63,8 +53,6 @@ jobs:
coverage: pcov
tools: composer:v2
- run: composer update --no-progress ${{ matrix.composer-flags }}
- run: composer require --dev --ignore-platform-reqs aws/aws-sdk-php:^3.147.3
if: ${{ matrix.upgrade-aws-sdk == 'yes' }}
- run: php test_files/wait_for_sftp.php
- run: php test_files/wait_for_ftp.php 2121
- run: php test_files/wait_for_ftp.php 2122
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/.php-cs-fixer.php
/.php-cs-fixer.cache
/google-cloud-service-account.json
.idea
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
# Version 2.x Changelog
# Changelog

## 3.0.1 - 2022-01-15

### Fixes

* [ZipArchive] delete top-level directory too when deleting a directory
* [GoogleCloudStorage] Use listing to check for directory existence (consistency)
* [GoogleCloudStorage] Fixed bug where exceptions were not thrown
* [AwsS3V3] Allow passing options for controlling multi-upload options (#1396)
* [Local] Convert windows-style directory separator to unix-style (#1398)

## 3.0.0 - 2022-01-13

### Added

* FilesystemReader::has to check for directory or file existence
* FilesystemReader::directoryExists to check for directory existence
* FilesystemReader::fileExists to check for file existence
* FilesystemAdapter::directoryExists to check for directory existence
* FilesystemAdapter::fileExists to check for file existence

## 2.4.0 - 2022-01-04

### Added

- [SFTP V3] New adapter officially published

## 2.3.2 - 2021-11-28

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2020 Frank de Jonge
Copyright (c) 2013-2022 Frank de Jonge

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 5 additions & 4 deletions bin/check-versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* - All required dependencies of the extracted packages MUST be
* present in the main composer.json's require(-dev) section.
* - Dependency constraints of extracted packages may not exclude
* the constrains of the main package and visa versa.
* the constraints of the main package and visa versa.
* - The provided target release argument must be satisfiable by
* all of the extracted packages' core dependency constraint.
*/
Expand All @@ -21,7 +21,7 @@
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\StorageAttributes;

include_once __DIR__.'/tools.php';
include_once __DIR__ . '/tools.php';


function constraint_has_conflict(string $mainConstraint, string $packageConstraint): bool
Expand Down Expand Up @@ -53,7 +53,7 @@ function constraint_has_conflict(string $mainConstraint, string $packageConstrai
write_line("🔎 Inspecting composer dependency incompatibilities.");

$mainVersion = $argv[1];
$filesystem = new Filesystem(new LocalFilesystemAdapter(__DIR__.'/../'));
$filesystem = new Filesystem(new LocalFilesystemAdapter(__DIR__ . '/../'));

$mainComposer = $filesystem->read('composer.json');
/** @var string[] $otherComposers */
Expand All @@ -69,7 +69,7 @@ function constraint_has_conflict(string $mainConstraint, string $packageConstrai
$information = json_decode($filesystem->read($composerFile), true);

foreach ($information['require'] as $dependency => $constraint) {
if (strpos($dependency, 'ext-') === 0) {
if (str_starts_with($dependency, 'ext-') || $dependency === 'phpseclib/phpseclib') {
continue;
}

Expand All @@ -79,6 +79,7 @@ function constraint_has_conflict(string $mainConstraint, string $packageConstrai
} else {
write_line("Composer file {$composerFile} allows league/flysystem:{$mainVersion} with {$constraint}");
}

continue;
}

Expand Down
4 changes: 2 additions & 2 deletions bin/set-flysystem-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\StorageAttributes;

include_once __DIR__.'/tools.php';
include_once __DIR__ . '/tools.php';

if ( ! isset($argv[1])) {
panic('No base version provided');
Expand All @@ -15,7 +15,7 @@

write_line("☝️ Setting all flysystem constraints to {$mainVersion}.");

$filesystem = new Filesystem(new LocalFilesystemAdapter(__DIR__.'/../'));
$filesystem = new Filesystem(new LocalFilesystemAdapter(__DIR__ . '/../'));

/** @var string[] $otherComposers */
$composerFiles = $filesystem->listContents('src', true)
Expand Down
2 changes: 1 addition & 1 deletion bin/tools.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include_once __DIR__.'/../vendor/autoload.php';
include_once __DIR__ . '/../vendor/autoload.php';

function write_line(string $line)
{
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
}
},
"require": {
"php": "^7.2 || ^8.0",
"php": "^8.0.2",
"ext-json": "*",
"league/mime-type-detection": "^1.0.0"
},
"require-dev": {
"ext-zip": "*",
"ext-fileinfo": "*",
"phpunit/phpunit": "^8.5 || ^9.4",
"phpunit/phpunit": "^9.5.11",
"phpstan/phpstan": "^0.12.26",
"phpseclib/phpseclib": "^2.0",
"aws/aws-sdk-php": "^3.132.4",
"aws/aws-sdk-php": "^3.198.1",
"composer/semver": "^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"google/cloud-storage": "^1.23",
Expand All @@ -35,7 +36,9 @@
"sabre/dav": "^4.1"
},
"conflict": {
"guzzlehttp/ringphp": "<1.1.1"
"symfony/http-client": "<5.2",
"guzzlehttp/ringphp": "<1.1.1",
"guzzlehttp/guzzle": "<7.0"
},
"license": "MIT",
"authors": [
Expand Down
5 changes: 5 additions & 0 deletions config.subsplit-publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"directory": "src/PhpseclibV2",
"target": "[email protected]:thephpleague/flysystem-sftp.git"
},
{
"name": "sftp-v3",
"directory": "src/PhpseclibV3",
"target": "[email protected]:thephpleague/flysystem-sftp-v3.git"
},
{
"name": "memory",
"directory": "src/InMemory",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/thephpleague/flysystem/blob/master/LICENSE)
[![Quality Assurance](https://github.com/thephpleague/flysystem/workflows/Quality%20Assurance/badge.svg?branch=2.x)](https://github.com/thephpleague/flysystem/actions?query=workflow%3A%22Quality+Assurance%22)
[![Total Downloads](https://img.shields.io/packagist/dt/league/flysystem.svg)](https://packagist.org/packages/league/flysystem)
![php 7.2+](https://img.shields.io/badge/php-min%207.2-red.svg)
![php 7.2+](https://img.shields.io/badge/php-min%208.0.2-red.svg)

## About Flysystem

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,11 @@ public function copy(string $source, string $destination, Config $config): void

$this->adapter->copy($source, $destination, $config);
}

public function directoryExists(string $path): bool
{
$this->throwStagedException(__METHOD__, $path);

return $this->adapter->directoryExists($path);
}
}
58 changes: 52 additions & 6 deletions src/AdapterTestUtilities/FilesystemAdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace League\Flysystem\AdapterTestUtilities;

use function is_resource;
use function iterator_to_array;
use const PHP_EOL;
use Generator;
use League\Flysystem\Config;
Expand Down Expand Up @@ -35,7 +37,7 @@ abstract class FilesystemAdapterTestCase extends TestCase
/**
* @var bool
*/
private $isUsingCustomAdapter = false;
protected $isUsingCustomAdapter = false;

public static function clearFilesystemAdapterCache(): void
{
Expand Down Expand Up @@ -77,8 +79,8 @@ protected function useAdapter(FilesystemAdapter $adapter): FilesystemAdapter
*/
public function cleanupAdapter(): void
{
$this->clearStorage();
$this->clearCustomAdapter();
$this->clearStorage();
}

public function clearStorage(): void
Expand Down Expand Up @@ -144,9 +146,11 @@ public function writing_a_file_with_a_stream(): void
$writeStream = stream_with_contents('contents');

$adapter->writeStream('path.txt', $writeStream, new Config());

if (is_resource($writeStream)) {
fclose($writeStream);
}

$fileExists = $adapter->fileExists('path.txt');

$this->assertTrue($fileExists);
Expand Down Expand Up @@ -197,9 +201,11 @@ public function writing_a_file_with_an_empty_stream(): void
$writeStream = stream_with_contents('');

$adapter->writeStream('path.txt', $writeStream, new Config());

if (is_resource($writeStream)) {
fclose($writeStream);
}

$fileExists = $adapter->fileExists('path.txt');

$this->assertTrue($fileExists);
Expand Down Expand Up @@ -302,6 +308,45 @@ public function listing_contents_shallow(): void
});
}

/**
* @test
*/
public function checking_if_a_non_existing_directory_exists(): void
{
$this->runScenario(function () {
$adapter = $this->adapter();
self::assertFalse($adapter->directoryExists('this-does-not-exist.php'));
});
}

/**
* @test
*/
public function checking_if_a_directory_exists_after_writing_a_file(): void
{
$this->runScenario(function () {
$adapter = $this->adapter();
$this->givenWeHaveAnExistingFile('existing-directory/file.txt');
self::assertTrue($adapter->directoryExists('existing-directory'));
});
}

/**
* @test
*/
public function checking_if_a_directory_exists_after_creating_it(): void
{
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->createDirectory('explicitly-created-directory', new Config());
self::assertTrue($adapter->directoryExists('explicitly-created-directory'));
$adapter->deleteDirectory('explicitly-created-directory');
$l = iterator_to_array($adapter->listContents('/', false), false);
self::assertEquals([], $l);
self::assertFalse($adapter->directoryExists('explicitly-created-directory'));
});
}

/**
* @test
*/
Expand Down Expand Up @@ -686,17 +731,18 @@ public function creating_a_directory(): void
$this->runScenario(function () {
$adapter = $this->adapter();

$adapter->createDirectory('path', new Config());
$adapter->createDirectory('creating_a_directory/path', new Config());

// Creating a directory should be idempotent.
$adapter->createDirectory('path', new Config());
$adapter->createDirectory('creating_a_directory/path', new Config());

$contents = iterator_to_array($adapter->listContents('', false));
$contents = iterator_to_array($adapter->listContents('creating_a_directory', false));
$this->assertCount(1, $contents, $this->formatIncorrectListingCount($contents));
/** @var DirectoryAttributes $directory */
$directory = $contents[0];
$this->assertInstanceOf(DirectoryAttributes::class, $directory);
$this->assertEquals('path', $directory->path());
$this->assertEquals('creating_a_directory/path', $directory->path());
$adapter->deleteDirectory('creating_a_directory/path');
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/AdapterTestUtilities/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
]
},
"require": {
"php": "^7.2 || ^8.0",
"league/flysystem": "^2.0.0"
"php": "^8.0.2",
"league/flysystem": "^2.0.0 || ^3.0.0"
},
"license": "MIT",
"authors": [
Expand Down
Loading

0 comments on commit bcee2f4

Please sign in to comment.