Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fregie committed Jun 16, 2023
1 parent 051b303 commit f827303
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ server:
-o server/output/${BUILD_NAME} ./server

server-aar: protobuf
CGO_ENABLED=0 gomobile bind -target=android -androidapi 19 -o android/app/libs/server.aar ./server/run
CGO_ENABLED=0 gomobile bind -target=android -androidapi 19 -ldflags "-s -w" -o android/app/libs/server.aar ./server/run

apk:
flutter build apk
Expand Down
Binary file modified android/app/libs/server.aar
Binary file not shown.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ require (
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
)

// replace github.com/studio-b12/gowebdav => ../gowebdav
// replace github.com/vmware/go-nfs-client => ../go-nfs-client
replace github.com/studio-b12/gowebdav => ../gowebdav
replace github.com/vmware/go-nfs-client => github.com/fregie/go-nfs-client v1.0.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 h1:DilThiXje
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349/go.mod h1:4GC5sXji84i/p+irqghpPFZBF8tRN/Q7+700G0/DLe8=
github.com/fregie/PrintVersion v0.1.0 h1:ElfIOjRlGxPGQ7IhkJpN3fp4cj1t1dQa6QBrsxowcjw=
github.com/fregie/PrintVersion v0.1.0/go.mod h1:rMKNhXgnKKCCBExlrh3xYI4dO07s30BQZXZeYBo+T8g=
github.com/fregie/go-nfs-client v1.0.0 h1:FqW9LwSdN0s44A9fHiBMMWJJ5WSje4FcGvlN520gv5A=
github.com/fregie/go-nfs-client v1.0.0/go.mod h1:PR0ieYaFWXw830/yR4KR3jIlZA5dtM3eq+EsSnJzi+M=
github.com/geoffgarside/ber v1.1.0 h1:qTmFG4jJbwiSzSXoNJeHcOprVzZ8Ulde2Rrrifu5U9w=
github.com/geoffgarside/ber v1.1.0/go.mod h1:jVPKeCbj6MvQZhwLYsGwaGI52oUorHoHKNecGT85ZCc=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
Expand Down Expand Up @@ -61,8 +63,6 @@ github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2 h1:VsBj3UD2xyA
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q=
github.com/vmware/go-nfs-client v0.0.0-20190605212624-d43b92724c1b h1:RUrsc0B9xF8iC8WXrva+ULeOwN/X+zqe0FdWcDxPt/M=
github.com/vmware/go-nfs-client v0.0.0-20190605212624-d43b92724c1b/go.mod h1:psQdhrCc+fimC/8/U+PboPiIMcdmKgRdAtcMnhXhjzI=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
6 changes: 3 additions & 3 deletions lib/gallery_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ class GalleryBodyState extends State<GalleryBody>
Navigator.push(
context,
PageRouteBuilder(
opaque: true,
opaque: false,
transitionDuration:
const Duration(milliseconds: 400),
const Duration(milliseconds: 300),
reverseTransitionDuration:
const Duration(milliseconds: 400),
const Duration(milliseconds: 300),
transitionsBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Expand Down
17 changes: 9 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MyApp extends StatelessWidget {
textTheme: textThemeLight,
navigationBarTheme: navigationBarThemeLight,
iconTheme: iconThemeLight,
floatingActionButtonTheme: floatingActionButtonThemeLight,
);
var darkTheme = ThemeData(
colorScheme: darkColorScheme,
Expand Down Expand Up @@ -123,14 +124,14 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
PreferredSizeWidget? appBar;
switch (_selectedIndex) {
case 0:
break;
case 1:
break;
case 2:
break;
}
// switch (_selectedIndex) {
// case 0:
// break;
// case 1:
// break;
// case 2:
// break;
// }
SnackBarManager.init(context);
return Consumer<StateModel>(
builder: (context, model, child) => Scaffold(
Expand Down
3 changes: 2 additions & 1 deletion lib/storage/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ class RemoteImage {
final request = http.Request('GET', Uri.parse(url));
final response = await client.send(request);
if (response.statusCode != 200) {
final errMsg = await response.stream.bytesToString();
throw Exception(
"get [$urlPath] thumbnail failed: ${response.statusCode}");
"get [$urlPath] thumbnail failed: [${response.reasonPhrase}] $errMsg");
}
await for (var data in response.stream) {
yield data as Uint8List;
Expand Down
7 changes: 5 additions & 2 deletions lib/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const textThemeDark = TextTheme(
const navigationBarThemeLight = NavigationBarThemeData(
height: 67,
iconTheme: MaterialStatePropertyAll(
IconThemeData(color: Color.fromARGB(255, 0, 44, 36)),
IconThemeData(color: Color.fromARGB(255, 0, 37, 30)),
),
labelTextStyle: MaterialStatePropertyAll(
TextStyle(
fontFamily: 'Ubuntu',
fontSize: 16,
color: Color.fromARGB(255, 0, 44, 36),
color: Color.fromARGB(255, 0, 37, 30),
height: 1,
),
),
Expand All @@ -54,3 +54,6 @@ const navigationBarThemeDark = NavigationBarThemeData(

const iconThemeLight = IconThemeData(color: Color.fromARGB(255, 0, 44, 36));
const iconThemeDark = IconThemeData(color: Color.fromARGB(255, 172, 196, 192));

const floatingActionButtonThemeLight = FloatingActionButtonThemeData(
backgroundColor: Color.fromARGB(255, 180, 227, 219));
53 changes: 22 additions & 31 deletions lib/video_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class _VideoRouteState extends State<VideoRoute> {
uri = "/$uri";
}
final url = "$httpBaseUrl$uri";
print(url);
videoPlayerController = VideoPlayerController.network(url);
}
await videoPlayerController.initialize();
Expand All @@ -57,6 +56,7 @@ class _VideoRouteState extends State<VideoRoute> {
looping: true,
showControlsOnInitialize: false,
showOptions: false,
customControls: const MaterialControls(),
);
setState(() {
isInitialized = true;
Expand All @@ -66,35 +66,26 @@ class _VideoRouteState extends State<VideoRoute> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: const Color(0x00000000),
iconTheme: const IconThemeData(color: Colors.white),
),
// body: Center(
// child: FutureBuilder(
// future: widget.asset.local!.originFile,
// builder: (context, file) {
// if (file.data != null) {
// final path = "file://${file.data!.absolute.path}";
// print(path);
// player.setDataSource(path, autoPlay: true, showCover: true);
// return FijkView(
// player: player,
// color: Colors.black,
// );
// }
// return Container();
// },
// ),
// ),
body: Center(
child: isInitialized
? Chewie(
controller: chewieController,
)
: const CircularProgressIndicator(),
),
);
backgroundColor: Colors.black,
body: Stack(
children: [
Center(
child: isInitialized
? Chewie(
controller: chewieController,
)
: const CircularProgressIndicator(),
),
Positioned(
top: 0,
left: 0,
right: 0,
child: AppBar(
backgroundColor: const Color(0x00000000),
iconTheme: const IconThemeData(color: Colors.white),
),
),
],
));
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.1.0+4
version: 1.2.0+5

environment:
sdk: '>=2.19.1 <3.0.0'
Expand Down
10 changes: 7 additions & 3 deletions server/drive/drive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (d *DriveTest) TestNFS() {
d.Nilf(err, "new nfs drive failed: %v", err)
err = dri.SetRootPath(nfsRootPath)
d.Nilf(err, "set root path failed: %v", err)

d.testDrive(dri)
d.testDownloadOffset(dri)
}

func (d *DriveTest) TestWebdav() {
Expand All @@ -65,6 +68,7 @@ func (d *DriveTest) TestWebdav() {
d.Nilf(err, "set root path failed: %v", err)

d.testDrive(dri)
d.testDownloadOffset(dri)
}

func (d *DriveTest) TestSMB() {
Expand Down Expand Up @@ -259,11 +263,11 @@ func (d *DriveTest) testDownloadOffset(dri imgmanager.StorageDrive) {
d.Nilf(err, "check exist failed: %v", err)
d.True(exist)
// test download
reader2, length, err := dri.DownloadWithOffset(filePath, 128)
reader2, length, err := dri.DownloadWithOffset(filePath, 256)
d.Nilf(err, "download failed: %v", err)
buf1 := make([]byte, 128)
buf1 := make([]byte, 256)
io.ReadFull(reader2, buf1)
reader2.Close()
d.Equal(static.Pic1[128:128+128], buf1)
d.Equal(static.Pic1[256:256+256], buf1)
d.Equal(int64(len(static.Pic1)), length)
}
47 changes: 33 additions & 14 deletions server/drive/nfs/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,43 @@ func (d *Nfs) Download(path string) (io.ReadCloser, int64, error) {
return nil, 0, fmt.Errorf("open file error: %v", err)
}
var length int64 = 0
// info, err := file.FSInfo()
// if err != nil {
// fmt.Printf("get file info error: %v\n", err)
// } else {
// length = int64(info.Size)
// }
// data, err := io.ReadAll(file)
// if err != nil {
// return nil, 0, err
// }
// length = int64(len(data))
// return io.NopCloser(strings.NewReader(string(data))), length, nil
d.updateLastConnTime()
info, _, err := d.cli.Lookup(fullPath)
if err != nil {
fmt.Printf("get file info error: %v\n", err)
} else {
length = int64(info.Size())
}
return file, length, nil
}

func (d *Nfs) DownloadWithOffset(path string, offset int64) (io.ReadCloser, int64, error) {
return nil, 0, fmt.Errorf("not support")
if err := d.checkConn(); err != nil {
return nil, 0, err
}
if d.rootPath == "" {
return nil, 0, fmt.Errorf("root path is empty")
}
fullPath := filepath.Join(d.rootPath, path)
file, err := d.cli.Open(fullPath)
if err != nil {
d.cleanLastConnTime()
return nil, 0, fmt.Errorf("open file error: %v", err)
}
var length int64 = 0
info, _, err := d.cli.Lookup(fullPath)
if err != nil {
fmt.Printf("get file info error: %v\n", err)
} else {
length = int64(info.Size())
}
if length > 0 && offset >= length {
return nil, length, fmt.Errorf("offset is out of range")
}
_, err = file.Seek(offset, io.SeekStart)
if err != nil {
return nil, length, err
}
return file, length, nil
}

func (d *Nfs) Delete(path string) error {
Expand Down
15 changes: 14 additions & 1 deletion server/drive/webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,20 @@ func (d *Webdav) Delete(path string) error {
}

func (d *Webdav) DownloadWithOffset(path string, offset int64) (io.ReadCloser, int64, error) {
return nil, 0, fmt.Errorf("not support")
if d.rootPath == "" {
return nil, 0, fmt.Errorf("root path is empty")
}
fullPath := filepath.Join(d.rootPath, path)
reader, err := d.cli.ReadStreamRange(fullPath, offset, -1)
if err != nil {
return nil, 0, err
}
info, err := d.cli.Stat(fullPath)
if err != nil {
return nil, 0, err
}

return reader, info.Size(), nil
}

func (d *Webdav) Upload(path string, reader io.ReadCloser, lastModified time.Time) error {
Expand Down

0 comments on commit f827303

Please sign in to comment.