aboutsummaryrefslogtreecommitdiffstats
path: root/src/update.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* update: merged addDirectoryPathToDB() into addParentPathToDB()Max Kellermann2008-10-111-23/+3
| | | | | | | The algorithm in addDirectoryPathToDB() can be simplified further if it is combined with the function addParentPathToDB(). Since there is no other caller of addDirectoryPathToDB(), we can do that. This saves another large stack buffer.
* update: make addDirectoryPathToDB() non-recursiveMax Kellermann2008-10-111-11/+13
| | | | | | This recursive function is very dangerous because it allocates a large buffer on the stack in every iteration. That may be misused to generate a stack overflow.
* update: delete directory after failed updateMax Kellermann2008-10-111-1/+8
| | | | | When a directory cannot be updated, there must be something wrong with it, and the database contains stale data. Remove it.
* update: moved code to directory_make_child_checked()Max Kellermann2008-10-111-22/+25
| | | | | | The branching looks a bit complicated in addDirectoryPathToDB() - improve its readability by moving code to a simplified separate function.
* update: clear root after errorMax Kellermann2008-10-111-0/+1
| | | | | When the root directory fails to update, its contents are invalid. Clear it then.
* update: locked delete after update errorMax Kellermann2008-10-111-1/+37
| | | | | | | When a directory failed to update, it was removed from the database, without freeing all children and songs (memory leak), and without locking (race condition). Introduce the functions clear_directory() and delete_directory(), which do both.
* update: removed addToDirectory()Max Kellermann2008-10-111-38/+10
| | | | | | Use updateInDirectory() instead of addToDirectory(). Eliminate a duplicate stat() in updateInDirectory() by calling song_file_update() directly.
* directory: added inline wrappers for accessing childrenMax Kellermann2008-10-111-6/+4
| | | | | Some tiny utilities... wrappers like these may become helpful when we introduce locking.
* directory: moved dirvec struct declaration to dirvec.hMax Kellermann2008-10-111-1/+0
| | | | | No idea why it was created in directory.h, but it should be in dirvec.h.
* directory: fix update in root directoryMax Kellermann2008-10-111-1/+1
| | | | | | | Commit 0bfe7802 broke update for new files in the root directory, because music_root->path was an empty string and not NULL. There were some NULL tests missing. Change them to !isRootDirectory(path) instead of path!=NULL.
* directory: eliminate CamelCaseMax Kellermann2008-10-111-6/+6
| | | | | | | | CamelCase is ugly, rename the functions. [ew: "directory_get_directory" was too confusing, using "directory_get_subdir" instead (old function was named "getSubDirectory")]
* database: renamed functions, "db_" prefix and no CamelCaseMax Kellermann2008-10-111-7/+7
| | | | Yet another CamelCase removal patch.
* directory: moved code to database.cMax Kellermann2008-10-111-1/+1
| | | | | | Taming the directory.c monster, part II: move the database management stuff to database. directory.c should only contain code which works on directory objects.
* song: song_file_update() returns booleanMax Kellermann2008-10-111-2/+2
| | | | | | | | | | | | | | Instead of returning 0 or -1, return true on success and false on failure. This seems more natural, and when the C library was designed, there was no "bool" data type. [ew: changing to bool semantics but sticking with integer type since bool is C99 and I don't require a C99 compiler, and I don't feel like writing compatibility wrappers to support it. _Bool is usually (always?) a signed int anyways. ]
* song: removed CamelCaseMax Kellermann2008-10-111-7/+7
| | | | CamelCase is ugly... rename all functions.
* song: replaced all song constructorsMax Kellermann2008-10-111-1/+1
| | | | | | Provide separate constructors for creating a remote song, a local song, and one for loading data from a song file. This way, we can add more assertions.
* song: converted typedef Song to struct songMax Kellermann2008-10-111-7/+7
| | | | | | | | | | | | | | | Again, a data type which can be forward-declared. [ew: * used "struct mpd_song" instead to avoid token duplication (like I did with "struct mpd_tag") as there's no good abbreviation for "song" and identical tokens on the same line don't read well * rewritten using perl -i -p -e 's/\bSong\b/struct mpd_song/g' src/*.[ch] since it was too hard to merge * also, I don't care much for forward declarations ]
* directory: converted typedef Directory to struct directoryMax Kellermann2008-10-111-20/+22
| | | | | The struct can be forward-declared by other headers, which relaxes the header dependencies.
* update: merged exploreDirectory() into updateDirectory()Max Kellermann2008-10-111-47/+13
| | | | | | exploreDirectory() duplicates some code in updateDirectory(). Merge both functions, and use directory_is_empty() to determine whether update or explore mode should be used.
* directory: moved code to update.cMax Kellermann2008-10-111-0/+560
The source directory.c mixes several libraries: directory object management, database management and database update, resulting in a 1000+ line monster. Move the whole database update code to update.c.