diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-04-14 02:55:19 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-04-14 02:55:19 +0000 |
commit | 8fa2084703096e4104c4e7422366a2e10e404891 (patch) | |
tree | b1473609951f58e662c9ca06ee55d4f31a9c5052 /src/directory.c | |
parent | 32b62ade7bb0ea58ee4a48822377a868d50c4230 (diff) | |
download | mpd-8fa2084703096e4104c4e7422366a2e10e404891.tar.gz mpd-8fa2084703096e4104c4e7422366a2e10e404891.tar.xz mpd-8fa2084703096e4104c4e7422366a2e10e404891.zip |
pseduo-code for creating new entries in db for incremental update
git-svn-id: https://svn.musicpd.org/mpd/trunk@743 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/directory.c')
-rw-r--r-- | src/directory.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/directory.c b/src/directory.c index 1ddc3af61..fd82f3fb1 100644 --- a/src/directory.c +++ b/src/directory.c @@ -363,18 +363,14 @@ int removeDeletedFromDirectory(Directory * directory) { void updatePath(char * utf8path) { Directory * directory; Directory * parentDirectory; + Song * song; char * shortname; + DIR * dir; - /* if path is already in the DB */ - if(NULL==(directory = getDirectoryDetails(utf8path,&shortname, + /* if path is in the DB try to update it, or else delete it */ + if((directory = getDirectoryDetails(utf8path,&shortname, &parentDirectory))) { - Song * song = getSongDetails(utf8path,&shortname,&directory); - if(song && updateSongInfo(song)<0) { - removeSongFromDirectory(directory,shortname); - } - } - else { /* if updateDirectory fials, means we should delete it */ if(updateDirectory(directory)<0 && directory!=mp3rootDirectory) { @@ -382,6 +378,22 @@ void updatePath(char * utf8path) { shortname); } } + else if((song = getSongDetails(utf8path,&shortname,&parentDirectory))) { + if(song && updateSongInfo(song)<0) { + removeSongFromDirectory(parentDirectory,shortname); + } + } + /* apth not found in the db, see if it actually exists on the fs */ + else if((dir = opendir(utf8path))) { + closedir(dir); + /* create parent/get parent directory */ + /* create new directory and add to parent */ + /* explore direcotry */ + } + else if((song = newSong(utf8path))) { + /* create parent/get parent directory */ + /* add song to directory */ + } } int updateDirectory(Directory * directory) { |