-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adaptors for SFTP/FTP #58
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking again path prefix does not double apply the prefix as comments state, but it should not be used anyways. get/setRoot
should be used instead.
src/Adapter/Sftp.php
Outdated
class Sftp extends SftpAdapter | ||
{ | ||
/** @var int */ | ||
protected $filePerm = 0644; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed. Parent has permPublic
and permPrivate
for this.
src/Adapter/Sftp.php
Outdated
*/ | ||
public function __construct(array $config) | ||
{ | ||
$this->configurable[] = 'filePerm'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configurable
just calls setters for config array. There is no setFilePerm
so this does nothing, also not needed as mentioned above.
src/Adapter/Sftp.php
Outdated
$location = $this->applyPathPrefix($path); | ||
|
||
return (bool) $this->getMetadata($location); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path prefix is already applied to connection object. This double applies it.
get/setRoot
should be used instead.
src/Adapter/Sftp.php
Outdated
} | ||
|
||
return $metadata; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is path
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see that our Filesystem::getTypeFromMetadata
needs it. That's a bug that should be fixed there instead.
// Right before getTypeFromMetadata call in doGetType method.
$metadata += ['path' => $path];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. 3222738
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks mate, well appreciated!
src/Adapter/Sftp.php
Outdated
} | ||
|
||
return parent::createDir($dirname, $config); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double applying path prefix.
get/setRoot
should be used instead.
src/Adapter/Ftp.php
Outdated
/** @var int */ | ||
protected $filePerm = 0664; | ||
/** @var int */ | ||
protected $directoryPerm = 0775; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be split into two values - one for public and one for private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, starting to get a picture of 6 months ago … A lot of running around in circles. 🤣
Upstream uses $directoryPerm
src/Adapter/Ftp.php
Outdated
*/ | ||
public function __construct(array $config) | ||
{ | ||
$this->configurable[] ='directoryPerm'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No setter, does nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bolt\Filesystem\Exception\IOException]
Notice: Undefined property: Bolt\Filesystem\Adapter\Ftp::$directoryPerm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct reply in the correct place always helps 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to tell without a stack trace, but that seems unrelated. You sure you didn't remove the class property and then still call it later in the class when getting that error?
Literally all $configurable
is for is to call setters for config options in setConfig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the constructor.
src/Adapter/Ftp.php
Outdated
$location = $this->applyPathPrefix($path); | ||
|
||
return (bool) $this->getMetadata($location); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This double applies path prefix.
get/setRoot
should be used instead.
src/Adapter/Ftp.php
Outdated
} | ||
|
||
return parent::createDir($dirname, $config); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This double applies path prefix.
get/setRoot
should be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
src/Adapter/Ftp.php
Outdated
{ | ||
try { | ||
$result = parent::createActualDirectory($directory, $connection); | ||
} catch (ContextErrorException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only thrown if Symfony's Error handler is hooked up. If you are trying to silence errors set a temporary error handler or use @
.
b86ee78
to
9bbe81e
Compare
OK, Monday … so let's get back to this 😄 Everything address, but the sole point for discussion (based on last review) was the use of The reasoning I went for a single class value is that matches the exact name & use in the upstream SFTP adaptor. Splitting that into two parameters would mean re-implementing several more methods in our SFTP adaptor, and I went with keeping the FTP one consistent. So impasse? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, other than the "for mirror() to work" comments. Filesystem
just needs a truthy value return or it throws an exception. mirror()
doesn't have anything to do with this.
OK … I got back to the bottom of this! So, the Now given the clueless I'll drop those bits and we can move on 👍 |
9bbe81e
to
b5e713b
Compare
Well for one we don't use Flysystem's |
Yeah, just pointing to the origin of what we were debating, not defending it. |
src/Adapter/Ftp.php
Outdated
class Ftp extends FtpAdapter | ||
{ | ||
/** @var int */ | ||
protected $directoryPerm = 0750; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sftp's default is 0744
. Should we update this one or that one to match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I had copy/pasta what I was using (over & over & over again) without thinking. It is a small but important distinction and you are 100% correct! Done.
b5e713b
to
958ba61
Compare
Getting CarsonF's attention for merge 😜
No description provided.