Пример #1
0
    public void DeleteVersion(uint version_id, bool remove_original)
    {
        if (version_id == OriginalVersionId && !remove_original)
        {
            throw new Exception("Cannot delete original version");
        }

        string path = GetVersionPath(version_id);

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        try {
            string thumb_path = ThumbnailGenerator.ThumbnailPath(path);
            File.Delete(thumb_path);
        } catch (System.Exception) {
            //ignore an error here we don't really care.
        }

        PhotoStore.DeleteThumbnail(path);

        version_names.Remove(version_id);

        do
        {
            version_id--;
            if (version_names.Contains(version_id))
            {
                DefaultVersionId = version_id;
                break;
            }
        } while (version_id > OriginalVersionId);
    }