Commit Graph

77 Commits

Author SHA1 Message Date
John Eikenberry fe93131e0a fix example request filesystem's file renaming
also added a test for the issue

Fixes #264
2018-08-17 11:59:53 -07:00
John Eikenberry d2aa419835 fix punctuation 2018-05-11 14:26:11 -07:00
John Eikenberry 161bbaf9a8 a few code simplifications
ran gosimple over the code and made suggested adjustments
2018-02-15 11:17:19 -08:00
John Eikenberry 02e35135dc test errors now set in a more uniform manner
request_test and request-server_test set mocked/fake errors differently.
This makes them use the same basic API for simplicity.
2018-01-16 14:18:45 -08:00
John Eikenberry 1a8a095942 add hooks for returning errors from test handlers
for use in tests, when I want to test error handling
2018-01-07 18:29:18 -08:00
Dave Cheney f2782dd6fa Move Request.handle to *Request
Updates #192

Move handle() onto *Request, this has flow on effects to the interface
types declared in request-interface.go, the examples and the tests.

The decision to address #192 started with advice from gopl.io, but I
think has uncovered several bugs as many of the request methods operate
on copies of data stored in the RequestServer's cache. I think this is
unintentional, but may point to some correctness issues, see #193.
2017-08-13 17:22:00 +10:00
John Eikenberry 733115c415 Fixes #184; better fix for file batching
I didn't like how the initial fix for #184 required the handler author
to track the token/offset for the filelist. I came up with a way to do
it that mimic'd the FileReader handler interface using a method
something like ReaderAt except for file lists.

changed MaxFileinfoList to a var for testing and tweaking

Renaming FileInfoer interface to FileLister.
FileInfoer -> FileLister
Fileinfo -> Filelist
2017-08-10 15:36:41 -07:00
John Eikenberry 314a5ccb89 keep 1.7 compat for now (remove a sort.Slice)
Not in performance critical code, so a more expensive option but
backward compatibile version is ok for now. Will switch back once 1.7
compatibility is no longer required.
2017-07-10 17:03:35 -07:00
John Eikenberry d02a2715ba Fixes #184; request server file list batching
The request server needs to support batching of file list requests. To
address this the methods LsSave(string) and LsNext()string are added to
the Request object. They should work to store a token to keep your place.

The Handler should now return an EOF when the end of the directory list is
reached. If it doesn't but returns an empty list, the wrapper will send the EOF
for you.

The old behaviour of just returning 1 batch and sending the EOF is preserved if
you don't set the token (you don't use LsSave). It will return the 1 list and
EOF on the next underlying readdir call. This is to preserve backwards
compatibility and it not the recommended way to handle file lists.
2017-07-10 16:43:58 -07:00
John Eikenberry a3c585f638 Fix several Setstat typos in request-server
Added a test that breaks w/ old code which has typos but is fixed with
typos fixed. Also added switch-default error message that would have
helped diagnose this (should have been there already).
2017-04-24 21:36:09 -07:00
John Eikenberry e1c86753b9 OS specific syscall.Stat_t use into separate file
The use of Stat_t in request-example.go is unix specific and broke the
Windows OS builds. This is the minimal change to fix that.

This fixes #157.
2017-02-24 20:06:51 -08:00
John Eikenberry 5d2bc88197 use modtime field instead of time.Now() 2017-02-18 18:20:37 -08:00
John Eikenberry ce4586e8a5 convert request to be pass by value
Encapsulate stateful data into sub-structures with pointer references
from the Request structure. This allows me to pass by value in most
cases to keep non-stateful (write once) data data race free and tightly
controlling access to stateful data to ease locking.
2017-02-18 18:20:37 -08:00
John Eikenberry 8cd6e6229d add lock to file access 2017-02-18 18:20:37 -08:00
John Eikenberry 94ae9c6822 fix issue with out-of-order packets 2017-02-18 18:20:37 -08:00
John Eikenberry 99921c4e1d add delay to writes based on length
To mimic write delays server side and introduce ordering errors.
2017-02-18 18:20:37 -08:00
John Eikenberry f18f3a1b48 govet fixes 2017-02-18 18:20:37 -08:00
John Eikenberry 9962211713 linter fixes 2017-02-18 18:20:37 -08:00
John Eikenberry 4974c76d49 remove some debug prints 2017-02-18 18:20:37 -08:00
John Eikenberry b387807529 Revert "have Stat() mimic os.Stat()'s error"
did this to make sure client received file not found error. changed
things so previous os.ErrNotExist works.
2017-02-18 18:20:37 -08:00
John Eikenberry d2ddc0b86f error if file rename target already exists 2017-02-18 18:20:37 -08:00
John Eikenberry 95dbe811f7 have Stat() mimic os.Stat()'s error 2017-02-18 18:20:37 -08:00
John Eikenberry e355d86d50 reordered and commented to improve as example 2017-02-18 18:20:37 -08:00
John Eikenberry 138f292b1b add symlink support to file mode info 2017-02-18 18:20:37 -08:00
John Eikenberry 584416ecbc FileInfo.Sys() returns a point to syscall.Stat_t
Returning the file stat struct with uid/gid set allows 'ls -l' to work
in sftp.
2017-02-18 18:20:37 -08:00
John Eikenberry 3f229eeee3 switch fs from tree to flat map
Simplify the example handlers FS-like struct by changing it from a tree
to a map.
2017-02-18 18:20:37 -08:00
John Eikenberry b7df6d6ef6 initial version of in-memory example/test request backend 2017-02-18 18:20:37 -08:00