This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository eradio.

View the commit online.

commit d4f4db38bba8dbf689ad1408426fd7966c4249d2
Author: politebot <[email protected]>
AuthorDate: Sat Oct 18 11:50:15 2025 -0500

    More error handling for faves, update README with XML format
---
 README.md       | 41 +++++++++++++++++++++++++++++++++++++++++
 src/favorites.c | 29 +++++++++++++++++++++++++++--
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 036f7d8..f0742a4 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,47 @@ A simple internet radio player built with the Enlightenment Foundation Libraries
 - List stations with their favicons
 - Play, pause, and stop radio streams
 - Search by station name, country, language, or tag
+- Save favorite radio stations locally
+- Add custom radio station URLs manually
+
+## Favorites Storage
+
+Favorite radio stations are saved locally in XML format at:
+```
+~/.config/eradio/favorites.xml
+```
+
+### XML Format
+
+The favorites file uses a simple XML structure to store station metadata:
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<favorites version="1">
+  <station uuid="station-uuid-here" name="Station Name"
+           url=""
+           favicon="http://example.com/icon.png"/>
+  <station uuid="another-uuid" name="Another Station"
+           url=""
+</favorites>
+```
+
+### Element Attributes
+
+Each `<station>` element can contain the following attributes:
+
+- **`uuid`** (optional): Unique identifier from the radio-browser.info API
+- **`name`** (optional): Human-readable station name
+- **`url`** (optional): Stream URL for the radio station
+- **`favicon`** (optional): URL to the station's favicon image
+
+**Note:** Either `uuid` or `url` must be present for a station entry to be valid. The `uuid` is used as the primary key when available, with `url` as fallback.
+
+### File Operations
+
+- The file is automatically created when you add your first favorite station
+- Favorites are saved atomically using a temporary file and rename operation
+- The file can be manually edited - changes will be loaded when the application starts
 
 ## Prerequisites
 
diff --git a/src/favorites.c b/src/favorites.c
index 1bf0b76..80cdf72 100644
--- a/src/favorites.c
+++ b/src/favorites.c
@@ -5,6 +5,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 #include "favorites.h"
 
@@ -188,12 +189,36 @@ void favorites_save(AppData *ad)
 
     eina_hash_foreach(ad->favorites, _favorites_save_cb, root);
 
-    xmlSaveFormatFileEnc(tmp, doc, "UTF-8", 1);
+    int xml_save_result = xmlSaveFormatFileEnc(tmp, doc, "UTF-8", 1);
     xmlFreeDoc(doc);
 
-    rename(tmp, path);
+    if (xml_save_result == -1) {
+        // XML save failed - could be disk space, permissions, etc.
+        if (ad->statusbar) {
+            elm_object_text_set(ad->statusbar, "Error: Could not save favorites (disk full?)");
+        }
+        unlink(tmp); // Clean up the temp file
+        free(tmp);
+        goto end;
+    }
+
+    if (rename(tmp, path) == -1) {
+        // Rename failed - could be filesystem issues
+        if (ad->statusbar) {
+            elm_object_text_set(ad->statusbar, "Error: Could not save favorites (filesystem error)");
+        }
+        unlink(tmp); // Clean up the temp file
+        free(tmp);
+        goto end;
+    }
+
     free(tmp);
 
+    // Success - provide feedback to user
+    if (ad->statusbar) {
+        elm_object_text_set(ad->statusbar, "Favorites saved successfully");
+    }
+
 end:
     if (dir) free(dir);
     if (path) free(path);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to