diff --git a/bin/server.dart b/bin/server.dart index 52bfd59..2fab444 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -50,11 +50,11 @@ Future _importPosts(fileUri) async { } // 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); // Write posts.json - await File('posts.json').writeAsString(json.encode(postsJson)); + await File('/data/posts.json').writeAsString(json.encode(postsJson)); // Delete file await file.delete(); @@ -70,11 +70,11 @@ Future _importPosts(fileUri) async { /// If an array is empty, do nothing. /// Delete posted post from posts.json Future _postRandomPost() async { - if (!File('posts.json').existsSync()) { + if (!File('/data/posts.json').existsSync()) { return; } - final postsJson = json.decode(await File('posts.json').readAsString()); + final postsJson = json.decode(await File('/data/posts.json').readAsString()); if (postsJson.isEmpty) { return; @@ -82,7 +82,7 @@ Future _postRandomPost() async { 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); @@ -91,8 +91,8 @@ Future _postRandomPost() async { void main(List args) async { // If posts.json does not exist, create it and write an empty array - if (!File('posts.json').existsSync()) { - await File('posts.json').writeAsString(json.encode([])); + if (!File('/data/posts.json').existsSync()) { + await File('/data/posts.json').writeAsString(json.encode([])); } // Import posts from files