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
This commit is contained in:
		| @@ -363,18 +363,14 @@ int removeDeletedFromDirectory(Directory * directory) { | |||||||
| void updatePath(char * utf8path) { | void updatePath(char * utf8path) { | ||||||
| 	Directory * directory; | 	Directory * directory; | ||||||
| 	Directory * parentDirectory; | 	Directory * parentDirectory; | ||||||
|  | 	Song * song; | ||||||
| 	char * shortname; | 	char * shortname; | ||||||
|  | 	DIR * dir; | ||||||
|  |  | ||||||
| 	/* if path is already in the DB */ | 	/* if path is in the DB try to update it, or else delete it */ | ||||||
| 	if(NULL==(directory = getDirectoryDetails(utf8path,&shortname, | 	if((directory = getDirectoryDetails(utf8path,&shortname, | ||||||
| 			&parentDirectory)))  | 			&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 fials, means we should delete it */ | ||||||
| 		if(updateDirectory(directory)<0 && directory!=mp3rootDirectory) | 		if(updateDirectory(directory)<0 && directory!=mp3rootDirectory) | ||||||
| 		{ | 		{ | ||||||
| @@ -382,6 +378,22 @@ void updatePath(char * utf8path) { | |||||||
| 					shortname); | 					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) { | int updateDirectory(Directory * directory) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Warren Dukes
					Warren Dukes