Comments (3)
That's interesting, what server are you using for this? Can you send me some test credentials I could use to replicate what you're getting on your side? This is a case of a FTP server I've never seen yet, it seems that somehow you're FTP server always say everything is going well but when queries it says there's nothing in this folder.
from filestash.
I'm using a docker based ftp server, delfer/alpine-ftp-server
. I don't have a URL for you to test this on, but if you do docker-compose up
with the following docker-compose.yaml
file you should be able to reproduce this locally:
version: "2"
services:
app:
container_name: filestash
image: machines/filestash
restart: always
ports:
- "8334:8334"
volumes:
- ./state/:/app/data/state/
demo:
image: delfer/alpine-ftp-server
environment:
- USERS=demo|foobar
container_name: demo
restart: always
volumes:
- ./demo:/ftp/demo
from filestash.
I noticed the same strange behaviour. In fact, it is even stranger than what @velicanu describes in the original post: as stated above, you can't read/download a file located in a subfolder on your FTP server except if there is a file with the same name located in the current directory of your FTP user (which in the case of filestash looks to be the home directory). There is no need that the file is the same, just it has to have the same name.
After many hours of investigations, it seems that the problem comes from FTP's LIST command itself, as I also replicated the strange behaviour only using FTP command lines.
Maybe the solution would be to change the way you check the existence of the file at the beginning of the Cat method: perform a ReadDir in the parent folder and check if it contains a file with corresponding filename, instead of using Stat
method.
I tried this on my side and it seems to work. I add in my message below the code I used to test my solution, but it may not be well written according to Go standards, as I never coded in Go before.
@mickael-kerjean Please let me know if you think my solution is good and if you want me to open a PR or if you implement the solution yourself. 🙂
func (f Ftp) Cat(path string) (reader io.ReadCloser, err error) {
fileExists := false
f.Execute(func(client *goftp.Client) error {
slashLastIndex := strings.LastIndex(path, "/") // split the path to get the parent path on one side and the filename on the other side
parentPath := path[0:slashLastIndex]
filename := path[slashLastIndex+1:]
var fileInfos []os.FileInfo
fileInfos, err = client.ReadDir(parentPath) // get the content of the parent folder
if err != nil {
return err
} else {
for _, fileInfo := range fileInfos { // check if a file in the parent folder matches the name of the file we want to read
fileExists = fileExists || fileInfo.Name() == filename
}
}
if fileExists { // if the file exists, read it
pr, pw := io.Pipe()
go func() {
err = client.Retrieve(path, pw)
if err != nil {
pr.CloseWithError(NewError("Problem", 409))
}
pw.Close()
}()
reader = pr
}
return nil
})
if reader == nil { // if we couldn't find the file, return an error
err = NewError(fmt.Sprintf("No file matches path %s", path), 404)
}
return reader, err
}
from filestash.
Related Issues (20)
- Trojan Virus Detected : You have cahnged my root user password HOT 1
- [bug] hover on the features section does not work (landing page).
- [Customize UI] Can I customize the User Interface of filestash using plugins or any other method. HOT 2
- [bug] [web] ftp doesn't work
- [Feature Request] How Could I enable LDAP in free version of Filestash HOT 2
- [bug] Can't login to admin page `Crypto/aes: invalid key size 13` HOT 2
- [bug] Retrieving Buckets from S3 Object storage to Filestash UI
- [bug] HTPASSWD and S3 Path Setup for Multiple Bucket Access HOT 1
- [bug] Download option disappears when viewing search results HOT 2
- [bug] Self-hosted Filestash serving static files very slowly and finally show a blank page
- [bug] Share link WebDAV doesn't work HOT 1
- [support] cannot add iframe to web
- [bug] vsftpd download issue HOT 7
- Share links remain even after deleting the file/directory HOT 1
- [Bug] Docker CA Certs are outdated HOT 5
- Fix polish locale HOT 1
- [bug] "Local" storage backend not available in latest docker container HOT 1
- [bug] Git not working HOT 2
- Unable to paste text into the editor using CTRL-V HOT 1
- OnlyOffice integration broken since refactor to make configuration dynamic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filestash.