use mounted file
This commit is contained in:
parent
6d5669c009
commit
4ffb74614e
|
@ -50,11 +50,11 @@ Future<void> _importPosts(fileUri) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read posts.json and add posts to it
|
// Read posts.json and add posts to it
|
||||||
final postsJson = json.decode(await File('posts.json').readAsString());
|
final postsJson = json.decode(await File('/data/posts.json').readAsString());
|
||||||
postsJson.addAll(posts);
|
postsJson.addAll(posts);
|
||||||
|
|
||||||
// Write posts.json
|
// Write posts.json
|
||||||
await File('posts.json').writeAsString(json.encode(postsJson));
|
await File('/data/posts.json').writeAsString(json.encode(postsJson));
|
||||||
|
|
||||||
// Delete file
|
// Delete file
|
||||||
await file.delete();
|
await file.delete();
|
||||||
|
@ -70,11 +70,11 @@ Future<void> _importPosts(fileUri) async {
|
||||||
/// If an array is empty, do nothing.
|
/// If an array is empty, do nothing.
|
||||||
/// Delete posted post from posts.json
|
/// Delete posted post from posts.json
|
||||||
Future<void> _postRandomPost() async {
|
Future<void> _postRandomPost() async {
|
||||||
if (!File('posts.json').existsSync()) {
|
if (!File('/data/posts.json').existsSync()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final postsJson = json.decode(await File('posts.json').readAsString());
|
final postsJson = json.decode(await File('/data/posts.json').readAsString());
|
||||||
|
|
||||||
if (postsJson.isEmpty) {
|
if (postsJson.isEmpty) {
|
||||||
return;
|
return;
|
||||||
|
@ -82,7 +82,7 @@ Future<void> _postRandomPost() async {
|
||||||
|
|
||||||
final post = postsJson.removeAt(Random().nextInt(postsJson.length));
|
final post = postsJson.removeAt(Random().nextInt(postsJson.length));
|
||||||
|
|
||||||
await File('posts.json').writeAsString(json.encode(postsJson));
|
await File('/data/posts.json').writeAsString(json.encode(postsJson));
|
||||||
|
|
||||||
await _postOnMastodon(post);
|
await _postOnMastodon(post);
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ Future<void> _postRandomPost() async {
|
||||||
|
|
||||||
void main(List<String> args) async {
|
void main(List<String> args) async {
|
||||||
// If posts.json does not exist, create it and write an empty array
|
// If posts.json does not exist, create it and write an empty array
|
||||||
if (!File('posts.json').existsSync()) {
|
if (!File('/data/posts.json').existsSync()) {
|
||||||
await File('posts.json').writeAsString(json.encode([]));
|
await File('/data/posts.json').writeAsString(json.encode([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import posts from files
|
// Import posts from files
|
||||||
|
|
Loading…
Reference in a new issue