Skip to content
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

Merged
merged 3 commits into from
Aug 10, 2017
Merged

Adaptors for SFTP/FTP #58

merged 3 commits into from
Aug 10, 2017

Conversation

GwendolenLynch
Copy link
Contributor

No description provided.

CarsonF
CarsonF previously requested changes Aug 1, 2017
Copy link
Member

@CarsonF CarsonF left a 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.

class Sftp extends SftpAdapter
{
/** @var int */
protected $filePerm = 0644;
Copy link
Member

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.

*/
public function __construct(array $config)
{
$this->configurable[] = 'filePerm';
Copy link
Member

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.

$location = $this->applyPathPrefix($path);

return (bool) $this->getMetadata($location);
}
Copy link
Member

@CarsonF CarsonF Aug 1, 2017

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.

}

return $metadata;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is path needed?

Copy link
Member

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];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. 3222738

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks mate, well appreciated!

}

return parent::createDir($dirname, $config);
}
Copy link
Member

@CarsonF CarsonF Aug 1, 2017

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.

/** @var int */
protected $filePerm = 0664;
/** @var int */
protected $directoryPerm = 0775;
Copy link
Member

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.

Copy link
Contributor Author

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

*/
public function __construct(array $config)
{
$this->configurable[] ='directoryPerm';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No setter, does nothing.

Copy link
Contributor Author

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  

Copy link
Contributor Author

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 🤣

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the constructor.

$location = $this->applyPathPrefix($path);

return (bool) $this->getMetadata($location);
}
Copy link
Member

@CarsonF CarsonF Aug 1, 2017

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.

}

return parent::createDir($dirname, $config);
}
Copy link
Member

@CarsonF CarsonF Aug 1, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

{
try {
$result = parent::createActualDirectory($directory, $connection);
} catch (ContextErrorException $e) {
Copy link
Member

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 @.

@GwendolenLynch GwendolenLynch force-pushed the feature/s-ftp branch 2 times, most recently from b86ee78 to 9bbe81e Compare August 4, 2017 14:14
@GwendolenLynch
Copy link
Contributor Author

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 protected $directoryPerm.

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?

Copy link
Member

@CarsonF CarsonF left a 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.

@GwendolenLynch
Copy link
Contributor Author

OK … I got back to the bottom of this!

So, the AdapterInterface::createDir() PHPDoc says that it returns array|false, where-as FilesystemInterface::createDir() PHPDoc says that it returns bool with the attached comment of "True on success, false on failure."

Now given the clueless <censored> that did those docblocks, it is entirely feasible that the Clueless Level was over 9,000. That, and our mirror() doesn't care what is returned by createDir(), so for once reading the upstream code was (originally) a disadvantage to me 🤣

I'll drop those bits and we can move on 👍

@CarsonF
Copy link
Member

CarsonF commented Aug 9, 2017

Well for one we don't use Flysystem's FilesystemInterface. And two that interface and the adapters usually do return different values in an attempt to reduce code in the adapter. But yeah in this case since we know the adapter is only going to be used with our filesystem it's ok just to return a bool.

@GwendolenLynch
Copy link
Contributor Author

Yeah, just pointing to the origin of what we were debating, not defending it. :shipit:

class Ftp extends FtpAdapter
{
/** @var int */
protected $directoryPerm = 0750;
Copy link
Member

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?

Copy link
Contributor Author

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.

@GwendolenLynch GwendolenLynch dismissed CarsonF’s stale review August 10, 2017 04:53

Getting CarsonF's attention for merge 😜

@CarsonF CarsonF merged commit fe6b5bb into master Aug 10, 2017
@CarsonF CarsonF deleted the feature/s-ftp branch August 10, 2017 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants