-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
new SMB storage backend #4770
new SMB storage backend #4770
Conversation
Test failed. |
Test passed. |
} | ||
|
||
public function isUpdatable($path) { | ||
return true; |
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.
hmm - smb/cifs shares can be read only as well
@icewind1991 Regarding testRoot: for further testing: grab a windows vm here: http://www.modern.ie/en-US/virtualization-tools#downloads |
Test passed. |
@icewind1991 Did you keep in mind the issue #2502 when implementing the new SMB storage backend? |
OC7 |
@icewind1991 I haven't read the code yet. Will it support streaming ? (ie not having to download a whole file when only the first MB is needed, for example for thumbnail generation or mimetype detection) |
No, that is a limitation of smbclient itself |
Would be good to check whether it's possible to tell smbclient to output the file contents to stdout instead of a target file (or pipe it). If that works, it might be possible to stream whatever comes from its stdout back to ownCloud, maybe using popen() and pipes. |
Awwwyeah, streaming/piping could work, this worked for me:
Seems it can work with put as well:
|
} | ||
|
||
public function isReadable($path) { | ||
return true; |
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 needs to either use file_exists() or fallback to the default impl that does just that.
Same for isUpdatable().
Always returning true might make callers believe that a file exists when it doesn't (scanFile())
Conflicts: apps/files_external/3rdparty/smb4php/smb.php apps/files_external/lib/smb.php
…rename not overwriting
Updated streamwrapper and storage. tested against a windows 8 VM and a samba server on Arch Linux. |
A new inspection was created. |
🚀 Test Passed. 🚀 |
|
||
require_once 'errors.php'; | ||
|
||
spl_autoload_register(function ($class) { |
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.
Can't this be done in a more automatic-autoload-approach, i.e. without registering your own autoloader?
Please add class documentation to all classes. E.g. it should be easily possible to see what the difference between RawConnection and Connection is. |
* $pipes[0] holds STDIN for smbclient | ||
* $pipes[1] holds STDOUT for smbclient | ||
*/ | ||
private $pipes; |
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.
Shouldn't these be available to subclasses? Personally, I think that the number of proper use-cases of private is just as limited as the number of use-cases for static.
A PHP Stream Wrapper for SMB would be pretty awesome. :-) |
@icewind1991 I started testing this, see some failing results here #4770 (comment) |
I'd say better rebase this first, it seems some issues might be caused by stuff that was fixed already on master. |
A new inspection was created. |
Do we really want to continue with the approach to fork smbclient processes? Even with a much better looking code base the basic mechanism remains - I'd prefer to have a native php module which uses samba libs to talk to smb/cifs shares directly. |
@DeepDiver1975 I think improving the existing approach using smbclient via exec is an acceptable intermediate step. |
One advantage I saw here is that the smbclient process is only started once, and its internal CLI is driven by @icewind1991 's code which should improve performance a bit as we don't need to restart the process for every command (stat, etc...) I'm still a bit afraid that this big change causes regressions. |
I agree that having a native php module would be the optimal solution but that wont be available in all situations |
🚀 Test Passed. 🚀 |
true - but installations not capable of installing a custom/self-built php module generally don't need access to smb shares |
* @return string | ||
*/ | ||
public function read() { | ||
return trim(fgets($this->pipes[1])); |
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.
Hmm. trim() on binary data?
superseded by #10673 |
New implementation of the SMB storage backend using a new wrapper for smbclient (https://github.com/icewind1991/SMB).
This improves the test-ability and maintainability of the SMB backend and hopefully helps with the various issues the current SMB backend has.
Tested it locally against an smb server running on arch, requires testing against a windows smb server.
cc @DeepDiver1975 @karlitschek