*
* Possible return values:
* - @c 0 on success
- * - @c DB_NOTFOUND if the playlist doesn't exist
+ * - @c ENOENT if the playlist doesn't exist
* - @c EINVAL if the playlist name is invalid
* - @c EACCES if the playlist cannot be read by @p who
*/
WITH_TRANSACTION(trackdb_playlist_get_tid(name, who,
tracksp, ntracksp, sharep,
tid));
+ /* Don't expose libdb error codes too much */
+ if(e == DB_NOTFOUND)
+ e = ENOENT;
return e;
}
* none, and the default sharing is private (if it is an owned one) or shared
* (otherwise).
*
+ * If neither @c tracks nor @c share are set then we only do an access check.
+ * The database is never modified (even to create the playlist) in this
+ * situation.
+ *
* Possible return values:
* - @c 0 on success
* - @c EINVAL if the playlist name is invalid
}
if(!playlist_may_write(name, who, s))
return EACCES;
+ /* If no change was requested then don't even create */
+ if(!share && !tracks)
+ return 0;
/* Set the new values */
if(share)
kvp_set(&k, "share", share);
* - @c 0 on success
* - @c EINVAL if the playlist name is invalid
* - @c EACCES if the playlist cannot be modified by @p who
- * - @c DB_NOTFOUND if the playlist doesn't exist
+ * - @c ENOENT if the playlist doesn't exist
*/
int trackdb_playlist_delete(const char *name,
const char *who) {
}
/* We've checked as much as we can for now, now go and attempt the change */
WITH_TRANSACTION(trackdb_playlist_delete_tid(name, who, tid));
+ if(e == DB_NOTFOUND)
+ e = ENOENT;
return e;
}