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
|
||||
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<void> _importPosts(fileUri) async {
|
|||
/// If an array is empty, do nothing.
|
||||
/// Delete posted post from posts.json
|
||||
Future<void> _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<void> _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<void> _postRandomPost() async {
|
|||
|
||||
void main(List<String> 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
|
||||
|
|
Loading…
Reference in a new issue