mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-09-27 22:07:51 +00:00
Fix Hetzner size storage
This commit is contained in:
parent
6f5ffa0f80
commit
5f13be9339
|
@ -150,7 +150,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
final List<dynamic> rawVolumes = dbGetResponse.data['volumes'];
|
final List<dynamic> rawVolumes = dbGetResponse.data['volumes'];
|
||||||
for (final rawVolume in rawVolumes) {
|
for (final rawVolume in rawVolumes) {
|
||||||
final int dbId = rawVolume['id'];
|
final int dbId = rawVolume['id'];
|
||||||
final int dbSize = rawVolume['size'];
|
final int dbSize = rawVolume['size'] * 1024 * 1024 * 1024;
|
||||||
final dbServer = rawVolume['server'];
|
final dbServer = rawVolume['server'];
|
||||||
final String dbName = rawVolume['name'];
|
final String dbName = rawVolume['name'];
|
||||||
final dbDevice = rawVolume['linux_device'];
|
final dbDevice = rawVolume['linux_device'];
|
||||||
|
|
|
@ -3,12 +3,26 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
class DiskSize {
|
class DiskSize {
|
||||||
const DiskSize({final this.byte = 0});
|
const DiskSize({final this.byte = 0});
|
||||||
|
|
||||||
|
DiskSize.fromKibibyte(final double kibibyte)
|
||||||
|
: this(byte: (kibibyte * 1024).round());
|
||||||
|
DiskSize.fromMebibyte(final double mebibyte)
|
||||||
|
: this(byte: (mebibyte * 1024 * 1024).round());
|
||||||
|
DiskSize.fromGibibyte(final double gibibyte)
|
||||||
|
: this(byte: (gibibyte * 1024 * 1024 * 1024).round());
|
||||||
|
|
||||||
final int byte;
|
final int byte;
|
||||||
|
|
||||||
double get kibibyte => byte / 1024.0;
|
double get kibibyte => byte / 1024.0;
|
||||||
double get mebibyte => byte / 1024.0 / 1024.0;
|
double get mebibyte => byte / 1024.0 / 1024.0;
|
||||||
double get gibibyte => byte / 1024.0 / 1024.0 / 1024.0;
|
double get gibibyte => byte / 1024.0 / 1024.0 / 1024.0;
|
||||||
|
|
||||||
|
DiskSize operator +(final DiskSize other) =>
|
||||||
|
DiskSize(byte: byte + other.byte);
|
||||||
|
DiskSize operator -(final DiskSize other) =>
|
||||||
|
DiskSize(byte: byte - other.byte);
|
||||||
|
DiskSize operator *(final double other) =>
|
||||||
|
DiskSize(byte: (byte * other).round());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
if (byte < 1024) {
|
if (byte < 1024) {
|
||||||
|
|
|
@ -78,7 +78,8 @@ class DiskStatus {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String deviceId = iterableProviderVolume.linuxDevice!.split('/').last;
|
final String deviceId =
|
||||||
|
iterableProviderVolume.linuxDevice!.split('/').last;
|
||||||
if (deviceId.contains(volume.model!) &&
|
if (deviceId.contains(volume.model!) &&
|
||||||
deviceId.contains(volume.serial!)) {
|
deviceId.contains(volume.serial!)) {
|
||||||
providerVolume = iterableProviderVolume;
|
providerVolume = iterableProviderVolume;
|
||||||
|
@ -86,8 +87,8 @@ class DiskStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final DiskVolume diskVolume = DiskVolume.fromServerDiscVolume(volume, providerVolume);
|
final DiskVolume diskVolume =
|
||||||
|
DiskVolume.fromServerDiscVolume(volume, providerVolume);
|
||||||
|
|
||||||
return diskVolume;
|
return diskVolume;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ExtendingVolumePage extends StatefulWidget {
|
||||||
class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
|
class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
minSize = widget.diskVolumeToResize.sizeTotal;
|
minSize = widget.diskVolumeToResize.sizeTotal + DiskSize.fromGibibyte(2);
|
||||||
_currentSliderGbValue = minSize.gibibyte;
|
_currentSliderGbValue = minSize.gibibyte;
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,8 @@ class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
|
||||||
_priceController.text =
|
_priceController.text =
|
||||||
(_euroPerGb * double.parse(_sizeController.text))
|
(_euroPerGb * double.parse(_sizeController.text))
|
||||||
.toStringAsFixed(2);
|
.toStringAsFixed(2);
|
||||||
minSize = widget.diskVolumeToResize.sizeTotal;
|
minSize =
|
||||||
|
widget.diskVolumeToResize.sizeTotal + DiskSize.fromGibibyte(2);
|
||||||
if (_currentSliderGbValue < 0) {
|
if (_currentSliderGbValue < 0) {
|
||||||
_currentSliderGbValue = minSize.gibibyte;
|
_currentSliderGbValue = minSize.gibibyte;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue