Esempio n. 1
0
        private void UpdateData()
        {
            // Check if data still exists.
            if (!File.Exists (this.DataPath))
            {
                throw new Exception (string.Format (Strings.Exception.MediaSaveData, this._id));
            }

            // Make sure data is in the right place.
            string currentdatapath = this.DataPath;
            this._currentstatus = this._status;

            if (currentdatapath != this.DataPath)
            {
                FileInfo file = new FileInfo (currentdatapath);
                file.MoveTo (this.DataPath);
            }

            // Remove old symlink if needed.
            if (this._currentstatus == SorentoLib.Enums.MediaStatus.Public || this._currentstatus == SorentoLib.Enums.MediaStatus.PublicTemporary)
            {
                if (this._currentpath != string.Empty)
                {
                    File.Delete (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + this._currentpath);
                }
            }

            // Create new symlink if needed.
            if (this._status == SorentoLib.Enums.MediaStatus.Public || this._status == SorentoLib.Enums.MediaStatus.PublicTemporary)
            {
                // Check if path exists, if not create it.
                if (!Directory.Exists (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + System.IO.Path.GetDirectoryName (this._path)))
                {
                    Directory.CreateDirectory (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + System.IO.Path.GetDirectoryName (this._path));
                }

                // Create a new symlink.
                UnixFileInfo unixfileinfo = new UnixFileInfo (this.DataPath);
                unixfileinfo.CreateSymbolicLink (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + this._path);
            }

            // Check if size changed.
            FileInfo fileinfo = new FileInfo (this.DataPath);
            this._size = fileinfo.Length;

            this._currentpath = this._path;
            this._currentstatus = this._status;
        }
Esempio n. 2
0
        private void Initalize()
        {
            this._id = Guid.NewGuid();
            this._createtimestamp = Date.CurrentDateTimeToTimestamp();
            this._updatetimestamp = Date.CurrentDateTimeToTimestamp();

            this._accesslevel = Enums.Accesslevel.Guest;
            this._usergroupids = string.Empty;

            this._status = Enums.MediaStatus.Temporary;
            this._currentstatus = Enums.MediaStatus.Temporary;

            this._path = string.Empty;
            this._currentpath = string.Empty;

            this._description = string.Empty;
            this._copyright = string.Empty;

            this._variantids = string.Empty;
        }